Skip to content

Commit c898c62

Browse files
committed
Add the chunksize argument to the function version of graph kernels.
1 parent 9710c63 commit c898c62

10 files changed

+3265
-3242
lines changed

gklearn/kernels/commonWalkKernel.py

Lines changed: 400 additions & 399 deletions
Large diffs are not rendered by default.

gklearn/kernels/marginalizedKernel.py

Lines changed: 273 additions & 271 deletions
Large diffs are not rendered by default.

gklearn/kernels/path_up_to_h.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,18 @@ def __kernel_do_naive(self, paths1, paths2):
373373
for key in all_paths]
374374
kernel = np.sum(np.minimum(vector1, vector2)) / \
375375
np.sum(np.maximum(vector1, vector2))
376+
377+
elif self.__k_func is None: # no sub-kernel used; compare paths directly.
378+
path_count1 = Counter(paths1)
379+
path_count2 = Counter(paths2)
380+
vector1 = [(path_count1[key] if (key in path_count1.keys()) else 0)
381+
for key in all_paths]
382+
vector2 = [(path_count2[key] if (key in path_count2.keys()) else 0)
383+
for key in all_paths]
384+
kernel = np.dot(vector1, vector2)
385+
376386
else:
377-
raise Exception('The given "k_func" cannot be recognized. Possible choices include: "tanimoto", "MinMax".')
387+
raise Exception('The given "k_func" cannot be recognized. Possible choices include: "tanimoto", "MinMax" and None.')
378388

379389
return kernel
380390

0 commit comments

Comments
 (0)