SMCLA Algorithm Documentationο
π Overviewο
The Soft MCLA (sMCLA) is a consensus clustering algorithm that combines soft membership matrices by treating clusters as vectors and grouping them into meta-clusters. This is the soft version of the MCLA ensemble algorithm.
βοΈ Class Definitionο
Class Name: SMCLA
class SMCLA:
def __init__(self, n_clusters: int):
self.n_clusters = n_clusters
Implements the soft MCLA algorithm that aggregates memberships by clustering cluster-vectors themselves and re-assigning to objects.
π Parametersο
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
β |
Number of consensus clusters to output |
π Usage Examplesο
from soft_clustering._smcla._smcla import SMCLA
import numpy as np
# Simulate 3 soft clusterings
soft1 = np.random.dirichlet(np.ones(3), size=100)
soft2 = np.random.dirichlet(np.ones(3), size=100)
soft3 = np.random.dirichlet(np.ones(3), size=100)
model = SMCLA(n_clusters=3)
labels = model.fit_predict([soft1, soft2, soft3])
print("Consensus Labels:", labels)
π₯ Input / π€ Outputο
Input to
fit_predict(soft_memberships):soft_memberships (list of np.ndarray): List of soft clustering matrices (shape N x K)
Returns:
labels (np.ndarray): Consensus clustering labels (length N)
π§ Methodsο
__init__(self, n_clusters: int): Initializes the model with number of consensus clusters.fit_predict(self, soft_memberships: List[np.ndarray]): Transposes all cluster matrices, clusters the vectors, and aggregates to produce final labels.
β
π οΈ Implementation Notesο
Clusters are treated as feature vectors for meta-clustering.
KMeans is applied to these vectors to create meta-clusters.
Each data point is re-assigned based on aggregated contributions from cluster-vectors.
Final assignment is the max-weighted cluster.
π Referenceο
Punera, K., & Ghosh, J. (2008). Consensus-Based Ensembles of Soft Clusterings.