简体   繁体   中英

Unable to work with Cluster_Ensembles library

To perform ensemble clustering, I am trying to use Cluster_Ensembles and for starter, I am using the code mentioned on the page, also mentioned below.

import numpy as np
import Cluster_Ensembles as CE
cluster_runs = np.random.randint(0, 50, (50, 15000))
consensus_clustering_labels = CE.cluster_ensembles(cluster_runs, verbose = True, N_clusters_max = 50)

And it is giving me the following error:

INFO: Cluster_Ensembles: cluster_ensembles: due to a rather large number of cells in your data-set, using only 'HyperGraph Partitioning Algorithm' (HGPA) and 'Meta-CLustering Algorithm' (MCLA) as ensemble consensus functions.

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-53a81900403c> in <module>
      1 cluster_runs = np.random.randint(0, 50, (50, 15000))
----> 2 consensus_clustering_labels = CE.cluster_ensembles(cluster_runs, verbose = True, N_clusters_max = 50)

~\Anaconda3\lib\site-packages\Cluster_Ensembles\Cluster_Ensembles.py in cluster_ensembles(cluster_runs, hdf5_file_name, verbose, N_clusters_max)
    294         function_names = ['CSPA', 'HGPA', 'MCLA']
    295 
--> 296     hypergraph_adjacency = build_hypergraph_adjacency(cluster_runs)
    297     store_hypergraph_adjacency(hypergraph_adjacency, hdf5_file_name)
    298 

~\Anaconda3\lib\site-packages\Cluster_Ensembles\Cluster_Ensembles.py in build_hypergraph_adjacency(cluster_runs)
    166     N_runs = cluster_runs.shape[0]
    167 
--> 168     hypergraph_adjacency = create_membership_matrix(cluster_runs[0])
    169     for i in xrange(1, N_runs):
    170         hypergraph_adjacency = scipy.sparse.vstack([hypergraph_adjacency,

~\Anaconda3\lib\site-packages\Cluster_Ensembles\Cluster_Ensembles.py in create_membership_matrix(cluster_run)
    890     cluster_run = np.asanyarray(cluster_run)
    891 
--> 892     if reduce(operator.mul, cluster_run.shape, 1) != max(cluster_run.shape):
    893         raise ValueError("\nERROR: Cluster_Ensembles: create_membership_matrix: "
    894                          "problem in dimensions of the cluster label vector "

NameError: name 'reduce' is not defined

Kindly guide me if I am missing something or how to tackle this error.

Because the following links deal with the error NameError: name 'reduce' is not defined , you might find them helpful:

To summarize them, your problem will be resolved by the following command:

pip install -U git+https://github.com/mvr320/Cluster_Ensembles

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM