- Introduced by
- Tadeusz Calinski, Jerzy Harabasz
- Year
- 1974
- Type
- Cluster quality metric
- Family
- Clustering Validation
What does it do?
The Calinski-Harabasz Index, also called the Variance Ratio Criterion, was introduced by Calinski and Harabasz in 1974 for cluster analysis.
It compares the between-cluster variance with the within-cluster variance of a partition, with a correction for the number of clusters and the number of data points. Higher values indicate a partition in which clusters are more separated and more compact.
The intuition behind the method
The index is modelled on the F-statistic from analysis of variance. A good partition places points in different clusters far apart (large between-cluster variance) and keeps points within the same cluster close to their centroid (small within-cluster variance). The ratio B/W captures this trade-off. Because adding clusters changes both terms, the raw ratio alone is not a fair basis for comparing different values of k, so the factor (n − k)/(k − 1) is applied as a correction for the number of clusters and the number of data points.
History
Calinski and Harabasz introduced the index in 1974 in the paper "A dendrite method for cluster analysis", published in Communications in Statistics. It was motivated by the F-statistic used in analysis of variance, which is the basis of the between/within decomposition.
When to use it
Use the Calinski-Harabasz Index when you have numeric feature vectors, a partition produced by a method such as k-means, and need a single score to compare candidate numbers of clusters on the same dataset. It is a reasonable first check when clusters are expected to be roughly convex and of similar size. Do not rely on it when clusters are elongated, ring-shaped or otherwise non-convex, when cluster densities or sizes differ greatly, or when the distance you need is not squared Euclidean, because the formula is built on squared Euclidean distances to centroids. In those cases, complement it with other validation measures or with domain knowledge.
Limitations and considerations
- Built on squared Euclidean distances to centroids, so it tends to favour convex clusters of similar size and spread
- Within-cluster variance is dominated by points far from their centroid, so the index is sensitive to outliers and to features with large numeric ranges
- Performance can deteriorate in high-dimensional feature spaces and for non-spherical cluster shapes
- Clusters with very different densities or sizes can lead to a ratio that favours a partition that does not match the structure a domain expert expects
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Combines between-cluster separation and within-cluster compactness in one ratio, so higher values indicate a partition that is both more separated and more compact
- The (n − k)/(k − 1) factor explicitly adjusts for the number of clusters and sample size, which is the main reason it is used for comparing different k
- Grounded in the ANOVA F-statistic, so the between/within decomposition is easy to explain to a statistically trained reader
- Requires only the data, the cluster labels and the centroids, so it is cheap to compute for many candidate values of k
Applications
- Choosing the number of clusters for a k-means-style partition of a numeric feature matrix, by computing the index over a range of candidate k values
- Comparing candidate partitions of the same dataset that were produced by a centroid-based method minimising squared Euclidean distances, such as k-means, with the same distance measure
- Screening partitions before a more detailed validation with silhouette or other internal measures, as an initial comparison rather than a final judgement
- Worked example: on one numeric dataset, the index computed over k = 4 to 8 was 2151.3, 2528.9, 2571.5, 2375.0 and 2305.1 respectively, so it selected k = 6. The average silhouette width over the same range was highest at k = 5 (about 0.47, compared with about 0.44 at k = 6). The two criteria therefore disagreed; the candidate range was narrowed to 5 or 6, and an SSE scree plot was then used to help make the final selection.
How it works
How it works
Compute the between-cluster variance B by summing, over all k clusters, the squared distance of each cluster centroid from the global centroid, weighted by the number of points in that cluster.
Formula
B = \sum_{r=1}^{k} n_r ||\mu_r - \mu||^2Compute the within-cluster variance W by summing, over all clusters, the squared distances of every point from its own cluster centroid.
Formula
W = \sum_{r=1}^{k} \sum_{i \in C_r} ||x_i - \mu_r||^2Calculate the index as B divided by W, multiplied by (n − k)/(k − 1), where n is the number of points and k is the number of clusters. Compute this for each candidate k and compare the values; the formula itself does not give an absolute threshold. The index is defined only for k ≥ 2 (the factor k − 1 must be positive) and for n > k (so that n − k is positive), so skip candidate values outside this range. It is also undefined when W = 0, for example when every point coincides with its cluster centroid, and such partitions cannot be scored.
Formula
CH = \frac{B}{W} \cdot \frac{n - k}{k - 1}Common pitfalls
- Treating the k that maximises the index as the true number of clusters; the maximum is a statistical suggestion and should be checked against domain knowledge and other validation measures
- Computing the index on unstandardised features, where a feature with a large numeric range contributes disproportionately to both B and W
- Using the index with a non-Euclidean distance or with cluster assignments from a method that does not minimise squared distances to centroids, which breaks the assumptions behind the formula
Frequently asked questions
What is a good Calinski-Harabasz Index value?
There is no universal threshold; the value depends on the dataset and its scale. The index is meant for comparison: compute it for different values of k on the same data and prefer the k that gives the largest value. Absolute values from different datasets are not directly comparable.
Can I use the Calinski-Harabasz Index to select the number of clusters?
Yes, this is one of its main uses. Compute the index for k over a reasonable range of candidate values and examine the k that maximises it, then check the result against domain knowledge and other measures. The maximum is only the best value among the k values tested, so if it lies at the lower or upper end of the range, values outside the range have not been examined and the range should be widened before a choice is made. If several values are close, compare them with a second criterion such as the silhouette score and with a visual inspection; the worked example in the applications section shows that the two criteria can disagree. It is a common complement to visual inspection of inertia curves, although it does not replace them.
How does the Calinski-Harabasz Index differ from the silhouette score?
The CH index is a ratio of between-cluster to within-cluster variance, computed from centroids and the global mean, and it is typically used to compare values of k. The silhouette score evaluates each point by comparing its distance to its own cluster with its distance to the nearest other cluster. They measure different aspects of a partition, so they are often reported together.
Is the Calinski-Harabasz Index sensitive to outliers?
Yes. The formula uses squared distances to centroids, so distant points contribute heavily to the within-cluster variance and can also shift centroids, which affects both terms of the ratio. Inspect or treat outliers before computing the index, or use a different validation approach.
Related methods
Sources
Calinski, T., & Harabasz, J. (1974). A dendrite method for cluster analysis. Communications in Statistics, 3(1), 1-27.
Open DOI referenceMachine Learning with R Important Book, p. 369