sknetwork-team / scikit-network

Graph Algorithms
Other
606 stars 66 forks source link

"TypeError: No matching signature found" while running Louvain() function from sknetwork #578

Closed vikram223 closed 1 month ago

vikram223 commented 2 months ago

Description

Tried to use Louvain() function on an adjacency matrix. It failed. Tried it on the karate_club() data and it still failed. So the example code in the scikit-network docs didn't work for me

IDE and running environment Anaconda with spyder conda 24.7.1

What I Did

from sknetwork.clustering import Louvain
from sknetwork.data import karate_club
louvain = Louvain()
adjacency = karate_club()
labels = louvain.fit_predict(adjacency)
len(set(labels))

Below is the traceback error

Traceback (most recent call last):

  File C:\ProgramData\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\...\....\....\...\getclusters.py:91
    labels = louvain.fit_predict(adjacency)

  File C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\base.py:64 in fit_predict
    self.fit(*args, **kwargs)

  File C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\louvain.py:276 in fit
    labels, increase = self._optimize(labels, adjacency, out_weights, in_weights)

  File C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\louvain.py:144 in _optimize
    return optimize_core(labels, indices, indptr, data, out_weights, in_weights, out_cluster_weights,

  File sknetwork\\clustering\\louvain_core.pyx:10 in sknetwork.clustering.louvain_core.__pyx_fused_cpdef

TypeError: No matching signature found
tbonald commented 2 months ago

Hello, This might be due to the IDE. Could you please try the same code outside the IDE (directly in Python)? Thanks.

vikram223 commented 2 months ago

It will take me too long to build an environment with pandas etc outside of Anaconda. I tested it without the Spyder IDE though and it still fails. I tested it under my WSL (Windows subsystem linux) anaconda ennvironment with python 3.9.19 and it works there. Unsure if the issue is the Windows env or the Python version.

(base) C:\.....\....\....>python
Python 3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sknetwork.clustering import Louvain
>>> from sknetwork.data import karate_club
>>> louvain = Louvain()
>>>     adjacency = karate_club()
  File "<stdin>", line 1
    adjacency = karate_club()
IndentationError: unexpected indent
>>> adjacency = karate_club()
>>> labels = louvain.fit_predict(adjacency)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\base.py", line 64, in fit_predict
    self.fit(*args, **kwargs)
  File "C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\louvain.py", line 276, in fit
    labels, increase = self._optimize(labels, adjacency, out_weights, in_weights)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\Lib\site-packages\sknetwork\clustering\louvain.py", line 144, in _optimize
    return optimize_core(labels, indices, indptr, data, out_weights, in_weights, out_cluster_weights,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sknetwork\\clustering\\louvain_core.pyx", line 10, in sknetwork.clustering.louvain_core.__pyx_fused_cpdef
TypeError: No matching signature found
>>>
tbonald commented 1 month ago

Hello, I am closing this issue as it seems related to your environment. Thanks.