-
Notifications
You must be signed in to change notification settings - Fork 103
Description
iam getting a following error while transforming the data in case of graph hopper kernel only.
dataset_name = "MUTAG" # Replace with the desired dataset name
dataset = fetch_dataset(dataset_name, verbose=True)
G = dataset['data'] # Graphs
y = dataset['target'] # Labels
G_train, G_test, y_train, y_test = train_test_split(G, y, test_size=0.2, random_state=42)
gk = GraphHopper(normalize=True,kernel_type='bridge')
'''graph hopper kernel instance'''
K_train = gk.fit_transform(G_train)
Extracting dataset MUTAG..
Parsing dataset MUTAG..
Parse was succesful..
Deleting unzipped dataset files..
Going back to the original directory..
ValueError Traceback (most recent call last)
Cell In[98], line 8
6 gk = GraphHopper(normalize=True,kernel_type='bridge')
7 '''graph hopper kernel instance'''
----> 8 K_train = gk.fit_transform(G_train)
File ~/anaconda3/lib/python3.9/site-packages/grakel/kernels/kernel.py:198, in Kernel.fit_transform(self, X, y)
195 self.fit(X)
197 # Transform - calculate kernel matrix
--> 198 km = self._calculate_kernel_matrix()
200 self._X_diag = np.diagonal(km)
201 if self.normalize:
File ~/anaconda3/lib/python3.9/site-packages/grakel/kernels/kernel.py:232, in Kernel._calculate_kernel_matrix(self, Y)
230 cache = list()
231 for (i, x) in enumerate(self.X):
--> 232 K[i, i] = self.pairwise_operation(x, x)
233 for (j, y) in enumerate(cache):
234 K[j, i] = self.pairwise_operation(y, x)
File ~/anaconda3/lib/python3.9/site-packages/grakel/kernels/graph_hopper.py:261, in GraphHopper.pairwise_operation(self, x, y)
258 elif y[0].shape[1] > m:
259 yp = yp[:, :m, :][:, :, :m]
--> 261 return self.metric_((xp.reshape(xp.shape[0], m_sq),) + x[1:],
262 (yp.reshape(yp.shape[0], m_sq),) + y[1:])
File ~/anaconda3/lib/python3.9/site-packages/grakel/kernels/graph_hopper.py:335, in bridge_kernel(x, y)
333 nodepair = (4-NA_i_NA_j_distances)/4
334 nodepair[nodepair < 0] = 0
--> 335 return np.dot(weight_matrix.flat, nodepair.flat)
File <array_function internals>:200, in dot(*args, **kwargs)
ValueError: shapes (196,) and (0,) not aligned: 196 (dim 0) != 0 (dim 0)
I have tried this with other kernel like random walk, shortest path and WL but there it is working.