ysig / GraKeL

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

RuntimeWarning: invalid value encountered in divide #6

Closed xia0pin9 closed 6 years ago

xia0pin9 commented 6 years ago

Got the following RuntimeWarning when using graphlet_sampling kernel:

/usr/local/lib/python2.7/site-packages/grakel/kernels/graphlet_sampling.py:313: RuntimeWarning: invalid value encountered in divide
  return np.divide(km, np.sqrt(np.outer(self._X_diag, self._X_diag)))

It is probobally caused by INF/NaN value. Not a major problem, but may correspond to some edge cases.

ysig commented 6 years ago

This is what happens in some kernels when having to do with corner cases (i.e. empty graphs etc). It is on the hand of the user to deal with the Inf/NaN on the result where the standard approach is to apply the numpy.nan_to_num function on the resulting kernel matrix.