GuyAllard / markov_clustering

markov clustering in python

Repository from Github https://github.comGuyAllard/markov_clusteringRepository from Github https://github.comGuyAllard/markov_clustering

Attribute error: Argmax not found

sanobarlala opened this issue · comments

Hi!
I am passing a undirected and weighted networkx graph, g
matrix = nx.to_scipy_sparse_matrix(g)

But when I try to run this code: result = mc.run_mcl(matrix,inflation=1.4)
clusters = mc.get_clusters(result)
mc.draw_graph(matrix, clusters, pos=positions, node_size=50, with_labels=False, edge_color="silver")

It gives me a Attribute error: Argmax not found

DO you know why its happening?

Appreciate the help :)

Hi,
I have not encountered that error before.

To help identify what is causing this, can you identify which of the three lines that you posted results in the error (e.g. is it caused by the run_mcl, get_clusters or the draw_graph function).

Additionally, can you let me know the exact versions that you are using for:
python
numpy
scipy
networkx
matplotlib

Thanks!

I think that the issue may be due to the sparse matrix format returned by networkx.

nx.to_scipy_sparse_matrix returns a sparse matrix in coo format, which is a matrix type that does not support arithmetic operations or slicing. The scipy.sparse.coo_matrix documentation states:

Once a matrix has been constructed, convert to CSR or CSC format for fast arithmetic and matrix vector operations

Can you try converting the matrix to either CSR or CSC format, then supply that to mcl.
e.g.

matrix = nx.to_scipy_sparse_matrix(g).tocsc()
result = mc.run_mcl(matrix,inflation=1.4)
clusters = mc.get_clusters(result)
mc.draw_graph(matrix, clusters, pos=positions, node_size=50, with_labels=False, edge_color="silver")

If that works, then I will look into outputting a warning message if a coo matrix is supplied to run_mcl

Hi,
So I tried converting to both the CSC and CSR formats, but it still gives me a argmax error. I have attached to this thread, what line the error occurs in and also the versions of all the packages you mentioned above.

Thanks.

2018-12-04_1128

2018-12-04_1135

2018-12-04_1135_001

Correction: I realized I put in m instead of matrix for line 5 result=mc.run_mcl, but I fixed it and I still get the same error of argmax not found.

OK, thanks for the update.
I will try and replicate the issue.

The issue is that your version of scipy (0.18.1) does not support argmax for sparse matrices - this was added in scipy 0.19.0.

I will update the requirements.

Modified setup.py to require scipy >= 0.19.0