Skip to main content

Calinski-Harabasz Index: The Variance Ratio Criterion

How the Calinski-Harabasz index evaluates clustering quality by measuring the ratio of between-cluster to within-cluster variance — fast, intuitive, and ideal for k-selection with convex clusters.

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:

CH = \frac{SS_B / (k - 1)}{SS_W / (n - k)}

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:

SS_B = \sum_{j=1}^{k} n_j \| \mu_j - \mu \|^2

Within-cluster scatter SS_W measures how spread out points are within each cluster:

SS_W = \sum_{j=1}^{k} \sum_{x_i \in C_j} \| x_i - \mu_j \|^2

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.

Cluster geometry
Preset
Well-Separated: 120 seeded points, cluster centroid X marks, global centroid star and connecting lines
Cluster A · X = centroidCluster B · X = centroidCluster C · X = centroid★ global centroid · dashed lines = SS_BSpread circles = SS_W

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.

Variance ratio, step by step
Phase
Step 1 / 6
Data Points
Data Points: two eight-point clusters; star is the global centroid, X marks are cluster centroids
Cluster A · X = centroidCluster B · X = centroid★ global centroid

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.

Number of clusters
Point 0: (-2.7500, -1.0000), cluster 1Point 1: (2.2272, -0.7501), cluster 2Point 2: (0.0428, 2.5119), cluster 3Point 3: (-2.6289, -0.5159), cluster 1Point 4: (1.7812, -1.1272), cluster 2Point 5: (0.7172, 2.5438), cluster 3Point 6: (-3.2518, -0.0633), cluster 1Point 7: (2.3848, -1.2219), cluster 2Point 8: (0.3475, 3.1269), cluster 3Point 9: (-3.4529, -0.8130), cluster 1Point 10: (2.7585, -1.5525), cluster 2Point 11: (0.2185, 3.6965), cluster 3Point 12: (-3.7354, -1.4262), cluster 1Point 13: (3.4474, -1.2083), cluster 2Point 14: (-0.1438, 3.2045), cluster 3Point 15: (-3.0475, -1.3669), cluster 1Point 16: (2.8747, -0.6842), cluster 2Point 17: (-0.6095, 3.0252), cluster 3Point 18: (-2.4826, -1.5149), cluster 1Point 19: (2.4607, -0.1509), cluster 2Point 20: (-0.6215, 2.2552), cluster 3Point 21: (-2.7522, -0.9667), cluster 1Point 22: (2.1963, -0.7887), cluster 2Point 23: (0.1075, 2.5219), cluster 3Point 24: (-2.6967, -0.4707), cluster 1Point 25: (1.8045, -1.2219), cluster 2Point 26: (0.7716, 2.6435), cluster 3Point 27: (-3.3745, -0.1052), cluster 1Point 28: (2.4154, -1.2352), cluster 2Point 29: (0.3275, 3.1721), cluster 3Point 30: (-3.4738, -0.8751), cluster 1Point 31: (2.8299, -1.5131), cluster 2Point 32: (0.1236, 3.7195), cluster 3Point 33: (-3.6720, -1.5205), cluster 1Point 34: (3.4667, -1.0801), cluster 2Point 35: (-0.1698, 3.1835), cluster 3Point 36: (-2.9982, -1.3700), cluster 1Point 37: (2.8292, -0.6371), cluster 2Point 38: (-0.6074, 2.9437), cluster 3Point 39: (-2.4185, -1.4413), cluster 1Centroid 1Centroid 2Centroid 3

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
k=2
37.781
k=3
401.396
k=4
309.098
k=5
264.080
k=6
239.058
k=7
220.760
k=8
259.761

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
PointxyClusterabs
0-2.7500-1.000010.68174.86710.8599
12.2272-0.750120.72604.33560.8325
20.04282.511930.75334.36400.8274
3-2.6289-0.515910.86024.40690.8048
41.7812-1.127220.96134.47120.7850
50.71722.543830.97874.04020.7578
6-3.2518-0.063311.08994.49240.7574
72.3848-1.221920.65964.82080.8632
80.34753.126930.68284.72450.8555
9-3.4529-0.813010.76415.16250.8520
102.7585-1.552520.82365.29250.8444
110.21853.696530.92885.28740.8243
12-3.7354-1.426211.01695.80640.8249
133.4474-1.208321.05685.40710.8046
14-0.14383.204530.65765.03900.8695
15-3.0475-1.366910.72635.33670.8639
162.8747-0.684220.75794.64340.8368
17-0.60953.025230.86294.69790.8163
18-2.4826-1.514910.97065.09670.8096
192.4607-0.150921.07363.97200.7297
20-0.62152.255231.14934.05910.7169
21-2.7522-0.966710.68154.84120.8592
222.1963-0.788720.72504.35330.8335
230.10752.521930.74944.33510.8271
24-2.6967-0.470710.85454.41300.8064
251.8045-1.221920.96054.56700.7897
260.77162.643530.97984.10430.7613
27-3.3745-0.105211.08794.61080.7640
282.4154-1.235220.65814.84740.8642
290.32753.172130.68374.77360.8568
30-3.4738-0.875110.76465.22210.8536
312.8299-1.513120.81725.29620.8457
320.12363.719530.93385.35040.8255
33-3.6720-1.520511.02195.83760.8249
343.4667-1.080121.05865.32120.8011
35-0.16983.183530.65885.03550.8692
36-2.9982-1.370010.72715.31090.8631
372.8292-0.637120.76254.57870.8335
38-0.60742.943730.86044.63020.8142
39-2.4185-1.441310.97235.02630.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.

Clustering metrics

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.

If you found this explanation helpful, consider sharing it with others.

Mastodon