fuzzyclust.validity.stability_selection#

fuzzyclust.validity.stability_selection(estimator, X, n_clusters_range=range(2, 11), n_splits=20, method='subsample', subsample=0.8, index='fuzzy_ari', random_state=None)[source]#

Stability of the partition against resampling, for every number of clusters.

A number of clusters that reflects structure in the data gives the same partition on different subsets of the data; a wrong one splits or merges groups arbitrarily and the partitions of two subsets disagree. Two protocols are implemented.

  • "subsample" (Ben-Hur, Elisseeff & Guyon, 2002): two random sub-samples of a fraction subsample of the data are clustered independently and their partitions compared on the samples they share.

  • "split" (Lange, Roth, Braun & Buhmann, 2004): the data are split into two halves, the estimator is fitted on each, the model of the first half predicts the memberships of the second half (predict_proba acts as the classifier of the original method), and the prediction is compared with the second half’s own partition.

The comparison uses a fuzzy partition index, by default the fuzzy adjusted Rand index, which is zero for chance agreement and so needs no further normalization (the raw fuzzy Rand index grows with \(c\) because pairs apart in both partitions count as agreement). The statistic to inspect is the distribution over splits: a stable \(c\) has a mean near one and a small spread.

Parameters:
estimatorfuzzyclust clusterer

Cloned and refitted for every value of n_clusters and every split.

Xarray_like of shape (n_samples, n_features)
n_clusters_rangeiterable of int, default=range(2, 11)
n_splitsint, default=20

Number of resampling repetitions per n_clusters.

method{“subsample”, “split”}, default=”subsample”
subsamplefloat, default=0.8

Fraction of the samples in every sub-sample ("subsample" only).

index{“fuzzy_ari”, “fuzzy_rand”, “fuzzy_jaccard”}, default=”fuzzy_ari”
random_stateint, RandomState instance or None
Returns:
pandas.DataFrame

Indexed by n_clusters with one column per split (split_0, …); table.mean(axis=1).idxmax() is the most stable \(c\).

References

[1]

A. Ben-Hur, A. Elisseeff, I. Guyon, “A stability based method for discovering structure in clustered data”, Pacific Symposium on Biocomputing 7, 6–17, 2002.

[2]

T. Lange, V. Roth, M. L. Braun, J. M. Buhmann, “Stability-based validation of clustering solutions”, Neural Computation 16(6), 1299–1323, 2004.

Examples

>>> from fuzzyclust.cluster import FCM
>>> from fuzzyclust.datasets import make_fuzzy_blobs
>>> from fuzzyclust.validity import stability_selection
>>> X, _ = make_fuzzy_blobs(n_clusters=4, random_state=0)
>>> table = stability_selection(FCM(random_state=0), X, range(2, 7), n_splits=5, random_state=0)
>>> int(table.mean(axis=1).idxmax())
4

Examples using fuzzyclust.validity.stability_selection#

Three routes to the number of clusters: merging, validity scan, and stability

Three routes to the number of clusters: merging, validity scan, and stability