clustering_accuracy_score

clustering_accuracy_score(y_true, y_pred)[source]

Calculate clustering accuracy.

The clustering accuracy assigns each cluster to a class by solving the linear sum assignment problem on the confusion matrix of the true target labels and cluster labels, then finds the accuracy.

Parameters:
y_truearray-like of shape (n_samples,)

Ground truth target labels.

y_predarray-like of shape (n_samples,)

Cluster labels to evaluate.

Returns:
scorefloat

The clustering accuracy.

Examples

>>> from aeon.benchmarking.metrics.clustering import clustering_accuracy_score
>>> clustering_accuracy_score([0, 0, 1, 1], [1, 1, 0, 0]) 
1.0