I am trying to fit several cluster algorithms on one or across several subsets of a data matrix
X, of shape (n_samples, n_features).
import numpy as np from sklearn.cluster import KMeans y_preds = list() for X_ in np.array_split(X, 10, axis=0): # for each subset of X dist = pairwise_distances(X_) # compute similarity matrix y_preds.append(KMeans().fit_predict(dist)) # aggregate predicted cluster
Although the resulting clusters are very similar across subsets, the cluster labels are (obviously) random.
How can I aggregate these labels to estimate which set of cluster(s) most robustly fit the data, and ideally get an single robust cluster estimate (i.e. finding the most robust clusters across iterations)?
In other words, is there some bagging procedure for clustering?