ysig / GraKeL

A scikit-learn compatible library for graph kernels
https://ysig.github.io/GraKeL/
Other
588 stars 96 forks source link

Calculate a default kernel value #11

Closed davide1995 closed 5 years ago

davide1995 commented 5 years ago

I was reading this introduction: https://ysig.github.io/GraKeL/dev/user_manual/longer_introduction.html

I exeuted the following lines:

from grakel import GraphKernel
H2O = [[[[0, 1, 1], [1, 0, 0], [1, 0, 0]], {0: 'O', 1: 'H', 2: 'H'}]]
H3O = [[[[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]], {0: 'O', 1: 'H', 2: 'H', 3:'H'}]]
gs_kernel = GraphKernel(kernel=dict(name="graphlet_sampling", n_samples=5))
gs_kernel.fit(H2O)

An error occurs on fit method:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/grakel/graph_kernels.py", line 290, in fit
    self.initialize_()
  File "/usr/local/lib/python3.7/site-packages/grakel/graph_kernels.py", line 430, in initialize_
    self.kernel_ = kernel(**params)
TypeError: __init__() got an unexpected keyword argument 'n_samples'

I'm using grakel 0.1a5 under python 3.7.1

ysig commented 5 years ago

You are right. Documentation is outdated at that point. n_samples is a field of a dictionary that goes under sampling. You can always checkout the given kernel [reference].(https://ysig.github.io/GraKeL/dev/generated/grakel.GraphletSampling.html#grakel.GraphletSampling)

So a correct statement would be: gs_kernel = GraphKernel(kernel=dict(name="graphlet_sampling", sampling=dict(n_samples=5)))

ysig commented 5 years ago

Fixed this issue here: https://github.com/ysig/GraKeL/commit/9b436bd115f9018519f0f6f29a03909b22dcacd5