Calinski–Harabasz Index Calculator
Paste your data points and cluster labels to get the Calinski–Harabasz index (variance ratio criterion), the BGSS/WGSS breakdown, per-cluster centroids, and the (N−k)/(k−1) scaling. Matches scikit-learn calinski_harabasz_score. No signup, nothing uploaded.
How it works
The Calinski–Harabasz index — also called the variance ratio criterion — measures how well a set of points is clustered by comparing the spread between clusters against the spread within them. It needs no ground-truth labels, which makes it an internal validity index: the standard way to judge a k-means, hierarchical, or DBSCAN result and to compare different choices of k. It was introduced by Caliński and Harabasz in 1974 and is what scikit-learn returns from calinski_harabasz_score.
For N points partitioned into k clusters, the tool computes four things, all with squared Euclidean distance:
- Centroids. The overall centroid
c = (1/N)·Σ xᵢ(mean of all points) and each cluster centroidc_q = (1/n_q)·Σ x. - BGSS — between-cluster dispersion. The trace of the between-group scatter:
BGSS = Σ_q n_q · ‖c_q − c‖². Large when cluster centroids are far apart — clusters are well separated. - WGSS — within-cluster dispersion. The trace of the within-group scatter:
WGSS = Σ_q Σ_{x∈C_q} ‖x − c_q‖². Small when points sit close to their own centroid — clusters are compact. - The index.
CH = (BGSS / WGSS) · ((N − k) / (k − 1)). The ratio rewards separated, compact clusters; the (N − k)/(k − 1) factor corrects for the number of clusters so different k are comparable. Higher is better, with no fixed upper bound.
The index is defined only for 1 < k < N; scikit-learn raises an error otherwise, and this tool shows a clear inline message. As a credibility check it also computes the total scatter TSS = Σ ‖xᵢ − c‖² independently and confirms the identity BGSS + WGSS = TSS. If WGSS is exactly zero (perfectly compact clusters) the ratio is infinite; matching scikit-learn, the tool reports 1.0 and flags the convention. The whole computation is O(N·d) in the number of points and dimensions, so it stays instant in the browser for the few-thousand-point inputs this tool accepts.
Worked examples
Frequently asked questions
Sources & references
- scikit-learn — Calinski-Harabasz Index (sklearn.metrics.calinski_harabasz_score): the between/within dispersion ratio scaled by (N−k)/(k−1), squared Euclidean, the 1 < k < N requirement, and the WGSS = 0 ⇒ 1.0 convention
- Caliński, T. & Harabasz, J. (1974) — A dendrite method for cluster analysis, Communications in Statistics 3(1), 1–27 (the original variance ratio criterion)
The formulas on this page were last cross-checked against these sources on 2026-07-12. The Calinski–Harabasz index is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled against scikit-learn.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.