rand_index#

rand_index(y_true: ArrayLike, y_pred: ArrayLike) float[source][source]#

Compute the Rand index for two segmentations.

Measures the similarity between two segmentations by comparing all pairs of samples. Wraps sklearn.metrics.rand_score.

Parameters:
y_truearray-like of shape (n_samples,)

True segment labels, as returned by predict().

y_predarray-like of shape (n_samples,)

Predicted segment labels, as returned by predict().

Returns:
float

Rand index in [0, 1]. Higher is better.

Examples

>>> rand_index([0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1])
1.0