Closed Alessi0X closed 4 years ago
Can you try installing the upcoming version of grakel 0.1a7 https://github.com/ysig/GraKeL/tree/0.1a7. I think this error was a typo when refactoring some code and it is fixed there.
Thanks!
Στις Σάβ, 1 Φεβ 2020 στις 9:00 μ.μ., ο/η Alessio notifications@github.com έγραψε:
I am using the Graphlet Sampling kernel with no sampling, i.e.
GK = grakel.GraphletSampling(n_jobs=None, normalize=False, verbose=False, random_state=None, k=this_k, sampling=None)
where this_k is user-defined.
However, it shows the following error
Traceback (most recent call last): File "/opt/rh/rh-python36/root/usr/lib64/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, *kwds)) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/multiprocessing/pool.py", line 44, in mapstar return list(map(args)) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/scipy/optimize/_differentialevolution.py", line 1265, in call return self.f(x, *self.args) File "main_benchmarkKernels.py", line 68, in myFitness thisKernelMatrix = GK.fit_transform(thisDataset) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/grakel/kernels/graphlet_sampling.py", line 309, in fit_transform self.fit(X) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/grakel/kernels/kernel.py", line 117, in fit self.initialize() File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/grakel/kernels/graphlet_sampling.py", line 229, in initialize self.nsamples = n_samples UnboundLocalError: local variable 'n_samples' referenced before assignment
By looking at the code a variable n_samples is assigned to self.nsamples even when sampling is None.
Maybe it's just a minor if/else issue?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ysig/GraKeL/issues/25?email_source=notifications&email_token=AGY7H2MC3OQIVIXI3BWKELDRAXBGVA5CNFSM4KOUZ52KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKLJFUQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY7H2J63IUWBSUXE7EGERDRAXBGVANCNFSM4KOUZ52A .
Will it be on pip soon? I forgot to mention that I installed grakel-dev
via pip.
Anyway, by doing a diff
on graphlet_sampling.py
between versions 0.1a7
and 0.1a6
there is only one mismatch line
< check_is_fitted(self, ['phi_X'])
---
> check_is_fitted(self, ['_phi_X'])
so I don't think version 0.1a7
sorts out this issue.
Yes it will but for now you can install it from git using pip, as:
pip install https://github.com/ysig/GraKeL/archive/0.1a7.zip
Στις Κυρ, 2 Φεβ 2020 στις 9:14 μ.μ., ο/η Alessio notifications@github.com έγραψε:
Will it be on pip soon? I forgot to mention that I installed grakel-dev via pip
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ysig/GraKeL/issues/25?email_source=notifications&email_token=AGY7H2MCITV3CLHFKSKC5PDRA4LTDA5CNFSM4KOUZ52KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKR6PCA#issuecomment-581166984, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY7H2M7KYBGJOTPF5PMCFTRA4LTDANCNFSM4KOUZ52A .
Hi ysig. I tried 0.1a7 and still the same exact error.
Hey @Alessi0X.
Firstly, sorry for answering the same thing twice. It was confusion.
Secondly, thanks a lot for the feedback. It is actually a bug from refactoring. I think it is fixed with my latest commit (please have a look :) and close this issue if so).
Thirdly, I do know which is your application, but generally not sampling graphlets, is considered a bad practice. It takes a lot of time and doesn't return good results.
Hi @ysig , thanks for you prompt reply. We now have a different error
"""
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/usr/local/lib/python3.7/site-packages/scipy/optimize/_differentialevolution.py", line 1265, in __call__
return self.f(x, *self.args)
File "<ipython-input-2-0c9b4930054e>", line 40, in myFitness
thisKernelMatrix = GK.fit_transform(thisDataset)
File "/usr/local/lib/python3.7/site-packages/grakel/kernels/graphlet_sampling.py", line 310, in fit_transform
self.fit(X)
File "/usr/local/lib/python3.7/site-packages/grakel/kernels/kernel.py", line 123, in fit
self.X = self.parse_input(X)
File "/usr/local/lib/python3.7/site-packages/grakel/kernels/graphlet_sampling.py", line 416, in parse_input
samples = self.sample_graphlets_(A, self.k_, self.n_samples_, self.random_state_)
TypeError: sample_graphlets() takes 1 positional argument but 4 were given
"""
I think now it works (I made a new commit). Can you confirm?
Yes indeed, works nicely.
Thanks!
Closing the issue
I am using the Graphlet Sampling kernel with no sampling, i.e.
GK = grakel.GraphletSampling(n_jobs=None, normalize=False, verbose=False, random_state=None, k=this_k, sampling=None)
where
this_k
is user-defined.However, when I do
GK.fit_transform()
on a dataset, it shows the following errorBy looking at the code (
graphlet_sampling.py
) a variablen_samples
is assigned toself.n_samples_
even whensampling
isNone
(line 229).Maybe it's just a minor
if/else
issue? Theif
branch at line 158 considers the case whensampling
isNone
and ends at line 160. Theelseif
branch starts at 161 and indeed declaresn_samples
, which can be assigned toself.n_samples
at line 229.Setup: Python 3.6.9 with grakel-dev==0.1a6