This page

Citing

Please consider citing the scikit-learn.

9.8.3.1. sklearn.metrics.adjusted_rand_score

sklearn.metrics.adjusted_rand_score(labels_true, labels_pred)

Rand index adjusted for chance

The Rand Index computes a similarity measure between two clusterings by considering all pairs of samples and counting pairs that are assigned in the same or different clusters in the predicted and true clusterings.

The raw RI score is then “adjusted for chance” into the ARI score using the following scheme:

ARI = (RI - Expected_RI) / (max(RI) - Expected_RI)

The adjusted Rand index is thus ensured to have a value close to 0.0 for random labeling independently of the number of clusters and samples and exactly 1.0 when the clusterings are identical (up to a permutation).

ARI is a symmetric measure:

adjusted_rand_score(a, b) == adjusted_rand_score(b, a)
Parameters :

labels_true : int array, shape = [n_samples]

Ground truth class labels to be used as a reference

labels_pred : array, shape = [n_samples]

Cluster labels to evaluate

Returns :

ari: float :

Similarity score between -1.0 and 1.0. Random labelings have an ARI close to 0.0. 1.0 stands for perfect match.

See also

-

References