kultzak / MCLA

MCLA Cluster Ensemble method
MIT License
5 stars 0 forks source link

MCLA from Cluster_Ensembles

A package for MCLA(Meta-CLustering Algorithm).

Installation

You need

In construction

From inside MCLA folder:

Usage

In Construction

import MCLA
import numpy as np
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)
#    => [0,0,0, 1,1,1]

======== original readme below =========

Cluster_Ensembles

A package for combining multiple partitions into a consolidated clustering. The combinatorial optimization problem of obtaining such a consensus clustering is reformulated in terms of approximation algorithms for graph or hyper-graph partitioning.

Installation

Cluster_Ensembles is written in Python and in C. You need Python 2.7, its Standard Library and the following packages:

The pip install Cluster_Ensembles command mentioned below should automatically detect and, if applicable, install or update any of the afore-mentioned dependencies.

As yet another prelimiary to running Cluster_Ensembles, you should also follow the few more instructions below.

On CentOS, Fedora or some Red Hat Linux distribution:

This will install the GNU C library that is required to run a 32-bit executable binary with a 64-bit Linux kernel. This executable is tasked with hyper-graph partitioning. Skipping this step would result in a bad ELF interpreter error message when subsequently trying to run the Cluster_Ensembles package.

On a Debian or Ubuntu platform, the following commands should yield the same outcome:

Upon completion of the steps outlined above, install Cluster_Ensembles by sending a request to the Python Package Index (PyPI) as follows:

Any missing third-party dependency should be automatically resolved. Please note that as part of the installation of this package, some code written in C that will later on be required by the Cluster_Ensembles package to determine a graph partition is automatically compiled under the hood and according to the specifications of your machine. You therefore need to ensure availability of CMake and GNU make on your operating system.

At any rate, to make sure that third-party dependecy software was automatically installed open a terminal window and type, for example, gpmetis -help. If you don't get a help screen, please manually install [METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering] (http://glaros.dtc.umn.edu/gkhome/metis/metis/overview). On Ubuntu run the command sudo apt-get install metis.

Usage

Say that you have an array of shape (M, N) where each row corresponds to a vector reporting the cluster label of each of the N samples comprising your dataset. It is possible that some of those samples have been left out of consideration from some of those M clusterings; in this case, the corresponding entry is tagged as NaN (numpy.nan).

The few lines below illustrate how to submit consensus clustering analysis such an cluster_runs (M, N) array of cluster labels. A vector holding the consensus clustering identities for each of the N samples in your dataset, consensus_clustering_labels, is returned.

Please note that those M vectors of clustering labels can correspond to partitions of the samples into distinct numbers of overall clusters. Cluster_Ensembles therefore offers the possibility of seeking a consensus clustering from the aggregation of a clustering of your dataset into, say, 10 groups, another clustering of a fraction of your samples into 5 clusters, yet another partition of your dataset into 20 clusters, etc. Those choices are entirely up to you. Pretty much all that is required for Cluster_Ensembles is an array of clustering vectors.

>>> 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)

References