Skip to content
Back to skills

Calinski Harabasz Score

ASecurity

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.

  • 3 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 11, 2026
documentationpython

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill calinski-harabasz-score --agent claude-code

Installs 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 with every re-scan.

Security grade badge for Calinski Harabasz Score
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-calinski-harabasz-score/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-calinski-harabasz-score)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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)`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.