Hoosier-Clusters / clusim

An extended package for clustering similarity
MIT License
64 stars 15 forks source link

error after reinstall #43

Open robban80 opened 4 months ago

robban80 commented 4 months ago

Hi, I have recently reinstalled my operating system and all python packages needed for the element-centric similarity score. When I rerun code that worked in my old setup I get an error.

I'm following the example here to compare two hierarchical clusterings: https://github.com/Hoosier-Clusters/clusim/blob/master/examples/CluSim%20Examples%20-%20application%20with%20hierarchical%20clustering.ipynb

from clusim.clustering import Clustering, remap2match
import clusim.sim as sim

cinp = Clustering().from_scipy_linkage(l1, dist_rescaled = True)
cout = Clustering().from_scipy_linkage(l2, dist_rescaled = True)

elsim = sim.element_sim(cinp, cout, r=1.0, alpha=0.9)

and get the following error:

line 977, in print_elementcentric_similarity elsim = sim.element_sim(cinp, cout, r=r, alpha=alpha) File "/home/robert/.local/lib/python3.10/site-packages/clusim/clusimelement.py", line 60, in element_sim result_tuple = element_sim_elscore(clustering1, clustering2, alpha=alpha, File "/home/robert/.local/lib/python3.10/site-packages/clusim/clusimelement.py", line 130, in element_sim_elscore clu_affinity_matrix1 = make_affinity_matrix(clustering1, alpha=alpha, r=r, File "/home/robert/.local/lib/python3.10/site-packages/clusim/clusimelement.py", line 221, in make_affinity_matrix cielg = make_cielg(clustering=clustering, r=r, File "/home/robert/.local/lib/python3.10/site-packages/clusim/clusimelement.py", line 338, in make_cielg cielg = igraph.Graph.Weighted_Adjacency(projected_adj.tolist(), AttributeError: 'csr_matrix' object has no attribute 'tolist'. Did you mean: 'tolil'?

ajgates42 commented 4 months ago

Hi @robban80, can you check the version of clusim you are using? that code looks old.

One fix could be to install the latest version using this: pip install pip@git+https://github.com/Hoosier-Clusters/clusim