kultzak/MCLA

TypeError: object of type 'int' has no len()

Opened this issue · 1 comments

It seems that the function MCLA.MCLA(cluster_runs, verbose = False, N_clusters_max = None) doesn't go well

Traceback (most recent call last):
File "/home/q1.py", line 333, in
ensemble_learning_mcla('finialdata/332SCL90.csv', 'SCL90', 3)
File "/home/q1.py", line 286, in ensemble_learning_mcla
clst = MCLA.MCLA(clusters, num_cluster)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/MCLA/MCLA.py", line 330, in MCLA
(edgecuts, parts) = metis.part_graph(G, N_clusters_max)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/sm0501/lib/python3.11/site-packages/pymetis/init.py", line 339, in part_graph
xadj, adjncy = _prepare_graph(adjacency, xadj, adjncy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/sm0501/lib/python3.11/site-packages/pymetis/init.py", line 266, in _prepare_graph
for i in range(len(adjacency)):
^^^^^^^^^^^^^^
TypeError: object of type 'int' has no len()

My code is your demo:
clusters = np.array([[1, 1, 1, 2, 2, 2], [1, 1, 2, 2, 2, 2]]) # not a list, but a np.array
num_cluster = 2
clst = MCLA.MCLA(clusters, num_cluster)
print(clst)

I tested like this

from dir ~/respos/MCLA_test

git clone https://github.com/kultzak/MCLA.git
cd MCLA
python3 -m venv myenv
source myenv/bin/activate
python3 setup.py install

mannually installed with pip3 install those libs:

  • metis
  • tables
  • scipy
  • scikit-learn
  • six
  • psutil

then the python3 ~/respos/MCLA_test/example/example.py run fine

python3 ~/repos/MCLA_test/example/example.py 
32
[0 0 0 1 1 1]