What Calinski-Harabasz Measures
The CH index (also called the Variance Ratio Criterion) answers a simple question: are your clusters compact and well-separated? It computes the ratio of between-cluster scatter to within-cluster scatter, normalized by degrees of freedom. Higher values mean better-defined clusters. Proposed by Calinski and Harabasz in 1974, it remains one of the most widely used internal clustering evaluation metrics.
Think of it as a signal-to-noise ratio for clustering. The “signal” is how far apart the cluster centers are from the overall data center (between-cluster variance). The “noise” is how spread out the points are within each cluster (within-cluster variance). A good clustering maximizes the signal relative to the noise.
Mathematical Definition
The CH index is defined as:
where k is the number of clusters and n is the total number of data points.
Between-cluster scatter SS_B measures how far cluster centroids are from the global centroid:
Within-cluster scatter SS_W measures how spread out points are within each cluster:
The (k-1) and (n-k) terms normalize for the number of clusters and samples, making CH comparable across different values of k.
Exploring CH Interactively
Switch between preset scenarios to see how cluster arrangement affects the CH index. Watch how SS_B and SS_W shift as clusters move closer, overlap, or take non-convex shapes.
Three tight, well-separated clusters produce a high CH index (1485.6). SS_B dominates because centroids are far from the global center, while SS_W is small because points cluster tightly.
How the Calculation Works
The computation follows a clear sequence. First, compute the global centroid from all data points. Then compute each cluster's centroid. SS_B accumulates the squared distance from each cluster centroid to the global centroid, weighted by cluster size — larger clusters contribute more. SS_W accumulates the squared distance from every point to its own cluster centroid. Finally, the ratio is normalized by degrees of freedom.
The degrees-of-freedom normalization is what makes CH fair across different values of k. Without it, increasing k would almost always increase SS_B (more centroids spread further from the global center) and decrease SS_W (smaller clusters are tighter). The (k-1) in the numerator and (n-k) in the denominator correct for this, penalizing unnecessary splits.
Press Play to follow the variance ratio on a simple 2-cluster example, or select a phase to inspect its distances and formula.
Selecting k with CH
The most common use of CH is ranking candidate numbers of clusters. Run the clustering algorithm for k = 2, 3, 4, \ldots, compute CH at each k, and pick the k that maximizes the score. The peak indicates where adding another cluster no longer improves the separation-to-spread ratio.
The (k-1) denominator naturally penalizes over-splitting — adding a cluster that doesn't meaningfully reduce SS_W will decrease CH. This built-in regularization makes CH more robust than raw inertia for k-selection, where the “elbow” can be ambiguous.
Select k to rerun deterministic k-means on the same 40 authored points. Inspect the resulting assignments and the calculated between/within sums. The peak is a property of these candidate clusterings, not a recovered ground truth.
Calculate CH across candidate clusterings
The same 40 authored 2D points are clustered at every k. Farthest-first initialization and Lloyd updates are deterministic. These are calculated toy results, not a benchmark or a recovered ground truth.
Colors indicate the calculated assignments; crosses are centroids. Coordinate units are arbitrary.
- Between SS
- 351.7732
- Within SS
- 16.2129
- CH = (B / (k − 1)) / (W / (40 − k))
- 401.3964
Highest candidate score: k=3. This comparison ranks these assignments under this metric; it does not prove the number of meaningful groups.
Inspect all point coordinates, assignments and distances
| Point | x | y | Cluster | a | b | s |
|---|---|---|---|---|---|---|
| 0 | -2.7500 | -1.0000 | 1 | 0.6817 | 4.8671 | 0.8599 |
| 1 | 2.2272 | -0.7501 | 2 | 0.7260 | 4.3356 | 0.8325 |
| 2 | 0.0428 | 2.5119 | 3 | 0.7533 | 4.3640 | 0.8274 |
| 3 | -2.6289 | -0.5159 | 1 | 0.8602 | 4.4069 | 0.8048 |
| 4 | 1.7812 | -1.1272 | 2 | 0.9613 | 4.4712 | 0.7850 |
| 5 | 0.7172 | 2.5438 | 3 | 0.9787 | 4.0402 | 0.7578 |
| 6 | -3.2518 | -0.0633 | 1 | 1.0899 | 4.4924 | 0.7574 |
| 7 | 2.3848 | -1.2219 | 2 | 0.6596 | 4.8208 | 0.8632 |
| 8 | 0.3475 | 3.1269 | 3 | 0.6828 | 4.7245 | 0.8555 |
| 9 | -3.4529 | -0.8130 | 1 | 0.7641 | 5.1625 | 0.8520 |
| 10 | 2.7585 | -1.5525 | 2 | 0.8236 | 5.2925 | 0.8444 |
| 11 | 0.2185 | 3.6965 | 3 | 0.9288 | 5.2874 | 0.8243 |
| 12 | -3.7354 | -1.4262 | 1 | 1.0169 | 5.8064 | 0.8249 |
| 13 | 3.4474 | -1.2083 | 2 | 1.0568 | 5.4071 | 0.8046 |
| 14 | -0.1438 | 3.2045 | 3 | 0.6576 | 5.0390 | 0.8695 |
| 15 | -3.0475 | -1.3669 | 1 | 0.7263 | 5.3367 | 0.8639 |
| 16 | 2.8747 | -0.6842 | 2 | 0.7579 | 4.6434 | 0.8368 |
| 17 | -0.6095 | 3.0252 | 3 | 0.8629 | 4.6979 | 0.8163 |
| 18 | -2.4826 | -1.5149 | 1 | 0.9706 | 5.0967 | 0.8096 |
| 19 | 2.4607 | -0.1509 | 2 | 1.0736 | 3.9720 | 0.7297 |
| 20 | -0.6215 | 2.2552 | 3 | 1.1493 | 4.0591 | 0.7169 |
| 21 | -2.7522 | -0.9667 | 1 | 0.6815 | 4.8412 | 0.8592 |
| 22 | 2.1963 | -0.7887 | 2 | 0.7250 | 4.3533 | 0.8335 |
| 23 | 0.1075 | 2.5219 | 3 | 0.7494 | 4.3351 | 0.8271 |
| 24 | -2.6967 | -0.4707 | 1 | 0.8545 | 4.4130 | 0.8064 |
| 25 | 1.8045 | -1.2219 | 2 | 0.9605 | 4.5670 | 0.7897 |
| 26 | 0.7716 | 2.6435 | 3 | 0.9798 | 4.1043 | 0.7613 |
| 27 | -3.3745 | -0.1052 | 1 | 1.0879 | 4.6108 | 0.7640 |
| 28 | 2.4154 | -1.2352 | 2 | 0.6581 | 4.8474 | 0.8642 |
| 29 | 0.3275 | 3.1721 | 3 | 0.6837 | 4.7736 | 0.8568 |
| 30 | -3.4738 | -0.8751 | 1 | 0.7646 | 5.2221 | 0.8536 |
| 31 | 2.8299 | -1.5131 | 2 | 0.8172 | 5.2962 | 0.8457 |
| 32 | 0.1236 | 3.7195 | 3 | 0.9338 | 5.3504 | 0.8255 |
| 33 | -3.6720 | -1.5205 | 1 | 1.0219 | 5.8376 | 0.8249 |
| 34 | 3.4667 | -1.0801 | 2 | 1.0586 | 5.3212 | 0.8011 |
| 35 | -0.1698 | 3.1835 | 3 | 0.6588 | 5.0355 | 0.8692 |
| 36 | -2.9982 | -1.3700 | 1 | 0.7271 | 5.3109 | 0.8631 |
| 37 | 2.8292 | -0.6371 | 2 | 0.7625 | 4.5787 | 0.8335 |
| 38 | -0.6074 | 2.9437 | 3 | 0.8604 | 4.6302 | 0.8142 |
| 39 | -2.4185 | -1.4413 | 1 | 0.9723 | 5.0263 | 0.8066 |
Strengths and Limitations
CH has several practical advantages. It runs in O(n \cdot d) time — no pairwise distance matrix needed, unlike Silhouette Score's O(n^2). The signal-to-noise interpretation is intuitive and easy to explain to stakeholders. It works well for convex, globular clusters produced by algorithms like k-means and GMM. The degrees-of-freedom normalization adjusts the comparison across different k values, so you can directly compare scores without additional correction.
However, CH has meaningful limitations. It assumes convex cluster shapes — the centroid of a crescent-shaped cluster lies in empty space, so SS_W is inflated and SS_B is misleading. It is sensitive to cluster size imbalance — a few small outlier clusters far from center can inflate SS_B disproportionately. It cannot evaluate a single cluster (k = 1 is undefined because of the (k-1) denominator). And it does not provide per-point diagnostics — you get one number for the entire clustering, with no way to identify which individual points are poorly assigned.
A geometry counterexample
For two concentric circles with 200 evenly spaced points on each, radii 1 and 2, the ring labels have Euclidean silhouette about 0.1148. Splitting those same points into left and right halves scores about 0.3522. The metric prefers the compact halves despite the ring structure. This is calculated on synthetic coordinates, not a model benchmark. The scikit-learn clustering guide documents this convexity bias.
Comparing Clustering Metrics
CH is one of several internal evaluation metrics. Each makes different geometric assumptions.
| Property | Calinski-Harabasz | Silhouette Score | Davies-Bouldin |
|---|---|---|---|
| Formula | SS_B / SS_W (normalized) | (b - a) / max(a, b) | avg max (σi+σj)/dij |
| Better When | Higher | Higher | Lower |
| Range | [0, ∞) | [-1, 1] | [0, ∞) |
| Complexity | O(n·k) | O(n²) | O(n·k) |
| Convexity Bias | Assumes convex | Euclidean convexity bias | Assumes convex |
| Best For | Fast k-selection with k-means | Diagnosing individual point assignments | Worst-case cluster overlap detection |
Calinski-Harabasz
- Formula
- SS_B / SS_W (normalized)
- Better When
- Higher
- Range
- [0, ∞)
- Complexity
- O(n·k)
- Convexity Bias
- Assumes convex
- Best For
- Fast k-selection with k-means
Silhouette Score
- Formula
- (b - a) / max(a, b)
- Better When
- Higher
- Range
- [-1, 1]
- Complexity
- O(n²)
- Convexity Bias
- Euclidean convexity bias
- Best For
- Diagnosing individual point assignments
Davies-Bouldin
- Formula
- avg max (σi+σj)/dij
- Better When
- Lower
- Range
- [0, ∞)
- Complexity
- O(n·k)
- Convexity Bias
- Assumes convex
- Best For
- Worst-case cluster overlap detection
Use CH when:
- You need fast computation (O(n·d)).
- Working with convex, globular clusters (k-means, GMM).
- Comparing different k values on the same dataset.
Consider alternatives when:
- Clusters are non-convex (crescents, rings): validate with domain labels, a justified geodesic distance, or a density-aware criterion. Euclidean silhouette has a convexity bias too.
- You need per-point diagnostics: use Silhouette.
- You want worst-case analysis: use Davies-Bouldin.
Related concepts
How the Davies-Bouldin index evaluates clustering quality by finding each cluster's most similar neighbor — a pessimistic, worst-case metric that catches overlapping cluster pairs.
How the silhouette score measures clustering quality for every individual point — comparing intra-cluster cohesion to nearest-cluster separation, with per-point diagnostics and explicit distance-metric assumptions.
Learn how IVF-PQ combines clustering and compression to enable billion-scale vector search with minimal memory footprint.
Explore an illustrative region-tiling policy: resize tiles, calculate visual tokens, and distinguish analytical savings from measured model quality.
Learn batch normalization in deep learning: how normalizing layer inputs accelerates training, improves gradient flow, and acts as regularization.
BatchNorm normalizes over the batch and spatial axes; LayerNorm normalizes over the channel and spatial axes for each sample. The choice changes whether your model trains stably with batch=1, depends on batch composition at inference, and behaves consistently across train and eval.
