ysig / GraKeL

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

Unable to transform same graph twice wth ShortestPath kernel #43

Closed kevinlee2198 closed 4 years ago

kevinlee2198 commented 4 years ago

Running GraKel version 0.1b7

Trying to run the H2O tutorial on the GraKel introduction, but noticed that I couldn't transform the same graph twice. Does fit_transform or transform do anything to the Graph object?

from grakel import Graph
from grakel.kernels import ShortestPath

H2O_adjacency = [[0, 1, 1], [1, 0, 0], [1, 0, 0]]
H2O = Graph(initialization_object=H2O_adjacency)

H3O_adjacency = [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]]
H3O = Graph(initialization_object=H3O_adjacency)

sp_kernel = ShortestPath(normalize=True, with_labels=False)
sp_kernel.fit_transform([H2O]) #works
sp_kernel.transform([H3O]) #works
sp_kernel.transform([H2O]) #error

Error on the second transform of H2O:

AttributeError: 'tuple' object has no attribute 'shape'
ysig commented 4 years ago

Thanks a lot for your feedback. The re-usability of shortest path matrices was indeed a feature that we promised.

Fixed with: https://github.com/ysig/GraKeL/commit/cefd7947b996d5f555e36e345ae8d51b4a732d12 and https://github.com/ysig/GraKeL/commit/fb708cccf33cfcfabd6ce5a8afb4c3185e3ad479