ysig / GraKeL

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

Random Walk Kernel #15

Closed kinsumliu closed 5 years ago

kinsumliu commented 5 years ago

To perform one step of random walk in the random walk kernel, we need to apply the adjacency matrix of the product graph to the probability of current node. In the line P*=XY, it is equivalent to np.multiply (element-wise multiplication). But we actually need np.matmul (matrix multiplication) instead. So the correct one should be P = np.matmul(XY, P) to perform one step of random walk.

if self.p is not None:
    P = np.eye(XY.shape[0])
    S = self._mu[0] * P
    for k in self._mu[1:]:
        P *= XY
        S += k*P
ysig commented 5 years ago

Thanks a lot for this correction. Changed it in the last commit of our upcoming version 0.1a6 https://github.com/ysig/GraKeL/commit/42d7aad88cdfaf80f235b3ce6e13fcfaecb00d50