You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When try to use NeighborhoodSubgraphPairwiseDistance as a base kernel to the WeisfeilerLehman, get the error that AttributeError: 'int' object has no attribute 'flags'.
To Reproduce
gk=WeisfeilerLehman(n_iter=2, normalize=True,
base_graph_kernel=(NeighborhoodSubgraphPairwiseDistance, {"verbose":True}), )
gk.fit(all_graphs) # all_graphs is a list of any `Graph` objectsgk.transform(all_graphs)
Expected behavior
A similarity matrix.
Stack Trace
---------------------------------------------------------------------------NotFittedErrorTraceback (mostrecentcalllast)
File/usr/local/lib/python3.10/dist-packages/grakel/kernels/weisfeiler_lehman.py:483, inWeisfeilerLehman.diagonal(self)
482try:
-->483check_is_fitted(self, ['_X_diag'])
484ifself._is_transformed:
File/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py:1661, incheck_is_fitted(estimator, attributes, msg, all_or_any)
1660ifnot_is_fitted(estimator, attributes, all_or_any):
->1661raiseNotFittedError(msg% {"name": type(estimator).__name__})
NotFittedError: ThisWeisfeilerLehmaninstanceisnotfittedyet. Call'fit'withappropriateargumentsbeforeusingthisestimator.
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
AttributeErrorTraceback (mostrecentcalllast)
CellIn[19], line1---->1gk.transform(all_graphs)
File/usr/local/lib/python3.10/dist-packages/sklearn/utils/_set_output.py:313, in_wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)
311 @wraps(f)
312defwrapped(self, X, *args, **kwargs):
-->313data_to_wrap=f(self, X, *args, **kwargs)
314ifisinstance(data_to_wrap, tuple):
315# only wrap the first output for cross decomposition316return_tuple= (
317_wrap_data_with_container(method, data_to_wrap[0], X, self),
318*data_to_wrap[1:],
319 )
File/usr/local/lib/python3.10/dist-packages/grakel/kernels/weisfeiler_lehman.py:452, inWeisfeilerLehman.transform(self, X)
450self._is_transformed=True451ifself.normalize:
-->452X_diag, Y_diag=self.diagonal()
453old_settings=np.seterr(divide='ignore')
454K=np.nan_to_num(np.divide(K, np.sqrt(np.outer(Y_diag, X_diag))))
File/usr/local/lib/python3.10/dist-packages/grakel/kernels/weisfeiler_lehman.py:493, inWeisfeilerLehman.diagonal(self)
491X_diag, Y_diag=self.X[0].diagonal()
492# X_diag is considered a mutable and should not affect the kernel matrix itself.-->493X_diag.flags.writeable=True494foriinrange(1, self._n_iter):
495x, y=self.X[i].diagonal()
AttributeError: 'int'objecthasnoattribute'flags'
Possible solution
If I haven't mistaken, and it's allowed to use this kernel with WeisfeilerLehman, so maybe the error goes from the fact that diagonal method of NeighborhoodSubgraphPairwiseDistance returns int and not numpy.array. I've done this, all works fine, but I'm not sure whether it is actually feasible.
The text was updated successfully, but these errors were encountered:
Describe the bug
When try to use
NeighborhoodSubgraphPairwiseDistance
as a base kernel to theWeisfeilerLehman
, get the error thatAttributeError: 'int' object has no attribute 'flags'
.To Reproduce
Expected behavior
A similarity matrix.
Stack Trace
Possible solution
If I haven't mistaken, and it's allowed to use this kernel with
WeisfeilerLehman
, so maybe the error goes from the fact thatdiagonal
method ofNeighborhoodSubgraphPairwiseDistance
returnsint
and not numpy.array. I've done this, all works fine, but I'm not sure whether it is actually feasible.The text was updated successfully, but these errors were encountered: