Open paolotgithub opened 4 years ago
I also experienced this issue when running
for inflation in [i / 10 for i in range(15, 26)]:
result = mc.run_mcl(matrix, inflation=inflation)
clusters = mc.get_clusters(result)
Q = mc.modularity(matrix=result, clusters=clusters)
print("inflation:", inflation, "modularity:", Q)
If you remove the [0]
from the following line, the code seems to work, but I'm not sure if that is functionally correct (i.e. if you're supposed to be plugging int the result matrix or the original matrix as @plttvmt suggested)
https://github.com/GuyAllard/markov_clustering/blob/28787cf64ef06bf024ff915246008c767ea830cf/markov_clustering/modularity.py#L37
I've noticed that this issue still exists when matrix
is a numpy array, so I proceeded to confirm whether @grgmiller 's approach is functionally correct, as he shared his concerns. Here is my procedure to confirm it.
modularity.py
(or whatever name you want to give to it).modularity.py
file from https://github.com/GuyAllard/markov_clustering/blob/28787cf64ef06bf024ff915246008c767ea830cf/markov_clustering/modularity.py[0]
from the line col = matrix[:,i].T.tolist()[0]
The solution provided by @grgmiller works for similarity matrices that are of numpy arrays type.
Dear all, how can you import modularity from your modularity.py file ? I give this error: 7 from itertools import permutations 9 from scipy.sparse import isspmatrix, dok_matrix, find ---> 10 from .mcl import sparse_allclose 12 def is_undirected(matrix): 13 """ 14 Determine if the matrix reprensents a directed graph 15 16 :param matrix: The matrix to tested 17 :returns: boolean 18 """
ImportError: attempted relative import with no known parent package
Thank you, best regards Charles
In calculating modularity Q I get the following error in my script that uses the markov_clustering package:
Shouldn't
Q = mc.modularity(matrix=result, clusters=clusters)
as it reads in the instructions be instead:
Q = mc.modularity(matrix, clusters=clusters)
?Or otherwise...?
Thanks a lot.