MACHINE LEARNING

Cluster Validation: Internal, External, and Relative Criteria

How do you know if your clusters are good? Internal criteria measure cohesion and separation from the data alone. External criteria compare to ground-truth labels. Relative criteria compare different clustering runs.

1Internal Validation: No Labels Required

Internal indices evaluate clustering quality using only the data and the cluster assignments — no ground-truth labels. They quantify two competing goals: cohesion (points within a cluster should be close to each other) and separation (clusters should be far from each other).

SSW (Within-cluster scatter)
Sum of squared distances from each point to its cluster centroid. Measures cohesion — lower is better. Used in the elbow method to pick K.
SSB (Between-cluster scatter)
Sum of squared distances from each cluster centroid to the global centroid, weighted by cluster size. Measures separation — higher is better.
Calinski-Harabasz index
Ratio SSB/SSW × (n-k)/(k-1). Higher = better-defined clusters. Like an F-ratio for clustering: penalises both poor separation and poor cohesion.

Silhouette coefficient: for each point xᵢ, let a(xᵢ) = mean distance to points in its own cluster, and b(xᵢ) = mean distance to points in the nearest other cluster. Then SC(xᵢ) = (b(xᵢ) - a(xᵢ)) / max(a(xᵢ), b(xᵢ)). Range: [-1, 1]. SC near 1 = point is well-matched to its cluster; near 0 = on a boundary; near -1 = probably in the wrong cluster. The mean SC across all points is the overall silhouette score.

2External Validation: Comparing to Ground Truth

External indices compare the clustering result to a known set of true class labels. They answer: does the algorithm recover the natural groupings? These are useful in research when you have labeled data but want to evaluate clustering without using labels during training.

For any pair of points (i, j) you can classify the pair into four categories based on whether the clustering and the ground truth agree:

  • a: same cluster AND same true class (true positive)
  • b: same cluster BUT different true class (false positive)
  • c: different cluster AND same true class (false negative)
  • d: different cluster AND different true class (true negative)
Rand Index
RI = (a + d) / (a + b + c + d). Fraction of pairs correctly classified by the clustering. Range [0,1]; 1 = perfect match. Naive baseline ≈ 0.5 for random clusters.
Jaccard Index
J = a / (a + b + c). Ignores true negatives (d) — only looks at pairs that should be together or are grouped together. More informative when most pairs are in different clusters.

3Relative Validation: Comparing Different Runs

Relative criteria compare multiple clustering results to find the best K or the best algorithm setting. No ground truth needed — you just run the algorithm many times and compare the internal index scores.

Elbow method: plot SSW vs. K. As K increases, SSW always decreases. The optimal K is at the "elbow" — where the rate of decrease drops sharply. Adding more clusters beyond the elbow gives diminishing returns in cohesion. Combine with silhouette scores to confirm: the silhouette peaks at the same K.

When to use internal criteria
Any unsupervised problem — you have no labels. Use silhouette + elbow to select K. Plot the silhouette for each K and pick the one with the highest mean score.
When to use external criteria
Benchmarking on labeled datasets, comparing algorithms. Use Adjusted Rand Index (ARI = RI corrected for chance) for fair comparison — standard RI can be inflated by a large number of pairs.

Related

Compute the silhouette coefficient from scratch with numpy

Recall check

0 of …

Say the answer out loud before revealing — recalling is what makes it stick. ➜ Next: PyTorch Basics

  1. What do a(xᵢ) and b(xᵢ) represent in the silhouette formula, and what does a high SC indicate?

  2. What do the four categories (a, b, c, d) represent in external cluster validation?

  3. What is the elbow method and how does it help choose K?

  4. Why is Adjusted Rand Index (ARI) preferred over the plain Rand Index for benchmarking?