as score is a np.ndarray (np.matrix is depreciated and data is not sparse) result is also a ndarray. This causes mc.modularity to crash on the function call convert_to_adjacency_matrix().
however in cases where some of the data doesnt belong to any clusters, this crashes.
The code functions correctly if
modularity = mc.modularity(matrix=np.matrix(result), clusters=clusters)
however np.matrix is depreciated.
the fix is fairly trivial
if isspmatrix(matrix):
col = find(matrix[:,i])[2]
else:
col = matrix[:,i].T.tolist()[0]
becomes
if isspmatrix(matrix):
col = find(matrix[:, i])[2]
elif isinstance(matrix, np.ndarray):
col = matrix[:, i].T.tolist()
else:
col = matrix[:, i].T.tolist()[0]
Could raise a PR but its only 2 lines of code, not sure whats easier.
as score is a np.ndarray (np.matrix is depreciated and data is not sparse) result is also a ndarray. This causes mc.modularity to crash on the function call convert_to_adjacency_matrix().
I found a quick fix which was to
modularity = mc.modularity(matrix=csr_matrix(result), clusters=clusters)
however in cases where some of the data doesnt belong to any clusters, this crashes. The code functions correctly if
modularity = mc.modularity(matrix=np.matrix(result), clusters=clusters)
however np.matrix is depreciated.the fix is fairly trivial
becomes
Could raise a PR but its only 2 lines of code, not sure whats easier.
Many thanks