Overview
Clustering metrics evaluate the quality of cluster assignments produced by unsupervised learning algorithms.Functions
silhouetteScore
Computes the mean Silhouette Coefficient over all samples.Feature matrix of shape [n_samples, n_features], or a precomputed distance matrix
Cluster labels for each sample
Distance metric:
'euclidean' (default) or 'precomputed'Number of samples to use for approximation (required when n > 2000)
Seed for reproducible sampling
Mean silhouette coefficient in range [-1, 1]
silhouetteSamples
Computes the Silhouette Coefficient for each sample.Feature matrix of shape [n_samples, n_features], or a precomputed distance matrix
Cluster labels for each sample
Distance metric:
'euclidean' (default) or 'precomputed'Tensor of silhouette coefficients in range [-1, 1] for each sample
daviesBouldinScore
Computes the Davies-Bouldin index.Feature matrix of shape [n_samples, n_features]
Cluster labels for each sample
Davies-Bouldin index (lower is better, 0 is minimum)
calinskiHarabaszScore
Computes the Calinski-Harabasz index (Variance Ratio Criterion).Feature matrix of shape [n_samples, n_features]
Cluster labels for each sample
Calinski-Harabasz index (higher is better)
adjustedRandScore
Computes the Adjusted Rand Index (ARI).Ground truth cluster labels
Predicted cluster labels
Adjusted Rand Index in range [-1, 1]
adjustedMutualInfoScore
Computes the Adjusted Mutual Information (AMI) between two clusterings.Ground truth cluster labels
Predicted cluster labels
Method to compute the normalizer:
'min', 'geometric', 'arithmetic' (default), or 'max'Adjusted Mutual Information score, typically in range [0, 1]
normalizedMutualInfoScore
Computes the Normalized Mutual Information (NMI) between two clusterings.Ground truth cluster labels
Predicted cluster labels
Method to compute the normalizer (default:
'arithmetic')Normalized Mutual Information score in range [0, 1]
fowlkesMallowsScore
Computes the Fowlkes-Mallows Index (FMI).Ground truth cluster labels
Predicted cluster labels
Fowlkes-Mallows score in range [0, 1]
homogeneityScore
Computes the homogeneity score of a clustering.Ground truth class labels
Predicted cluster labels
Homogeneity score in range [0, 1]
completenessScore
Computes the completeness score of a clustering.Ground truth class labels
Predicted cluster labels
Completeness score in range [0, 1]
vMeasureScore
Computes the V-measure score of a clustering.Ground truth class labels
Predicted cluster labels
Weight of homogeneity vs completeness (default: 1.0)
V-measure score in range [0, 1]