Compute the calinski_harabasz_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute calinski_harabasz_score, or asks how to score with calinski_harabasz_score.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add qhjqhj00/research-skills-pool --skill calinski-harabasz-score --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Calinski Harabasz Score?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/qhjqhj00-calinski-harabasz-score)More formats (shields.io, HTML) on the badges page.
---
name: calinski-harabasz-score
description: Compute the calinski_harabasz_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute calinski_harabasz_score, or asks how to score with calinski_harabasz_score.
metadata:
skill_kind: metric
source_lib: scikit-learn
import_path: sklearn.metrics.calinski_harabasz_score
source: library_introspection
---
# calinski-harabasz-score
> Metric `calinski_harabasz_score` from `scikit-learn` (sklearn.metrics.calinski_harabasz_score)
## When to invoke this skill
The user has predictions + ground truth and asks to evaluate with calinski_harabasz_score, or
mentions `sklearn.metrics.calinski_harabasz_score` directly, or wants the standard scikit-learn implementation.
## Reference signature
```python
from sklearn.metrics import calinski_harabasz_score
# calinski_harabasz_score(X, labels)
```
## Library docstring
```
Compute the Calinski and Harabasz score.
It is also known as the Variance Ratio Criterion.
The score is defined as ratio of the sum of between-cluster dispersion and
of within-cluster dispersion.
Read more in the :ref:`User Guide <calinski_harabasz_index>`.
Parameters
----------
X : array-like of shape (n_samples, n_features)
A list of ``n_features``-dimensional data points. Each row corresponds
to a single data point.
labels : array-like of shape (n_samples,)
Predicted labels for each sample.
Returns
-------
score : float
The resulting Calinski-Harabasz score.
References
----------
.. [1] `T. Calinski and J. Harabasz, 1974. "A dendrite method for cluster
analysis". Communications in Statistics
<https://www.tandfonline.com/doi/abs/10.1080/03610927408827101>`_
Examples
--------
>>> from sklearn.datasets import make_blobs
>>> from sklearn.cluster import KMeans
>>> from sklearn.metrics import calinski_harabasz_score
>>> X, _ = make_blobs(random_state=0)
>>> kmeans = KMeans(n_clusters=3, random_state=0,).fit(X)
>>> calinski_harabasz_score(X, kmeans.labels_)
114.8...
```
## Quick recipe
```python
import sklearn.metrics as _m
score = _m.calinski_harabasz_score(y_true, y_pred)
```
## Don'ts
- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!