Skip to content
Back to skills

Normalized Mutual Info Score

ASecurity

Compute the normalized_mutual_info_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute normalized_mutual_info_score, or asks how to score with normalized_mutual_info_score.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 11, 2026
documentationpython

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill normalized-mutual-info-score --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Normalized Mutual Info Score?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Normalized Mutual Info Score
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-normalized-mutual-info-score/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-normalized-mutual-info-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: normalized-mutual-info-score
description: Compute the normalized_mutual_info_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute normalized_mutual_info_score, or asks how to score with normalized_mutual_info_score.
metadata:
  skill_kind: metric
  source_lib: scikit-learn
  import_path: sklearn.metrics.normalized_mutual_info_score
  source: library_introspection
---

# normalized-mutual-info-score

> Metric `normalized_mutual_info_score` from `scikit-learn` (sklearn.metrics.normalized_mutual_info_score)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with normalized_mutual_info_score, or
mentions `sklearn.metrics.normalized_mutual_info_score` directly, or wants the standard scikit-learn implementation.

## Reference signature

```python
from sklearn.metrics import normalized_mutual_info_score

# normalized_mutual_info_score(labels_true, labels_pred, *, average_method='arithmetic')
```

## Library docstring

```
Normalized Mutual Information between two clusterings.

Normalized Mutual Information (NMI) is a normalization of the Mutual
Information (MI) score to scale the results between 0 (no mutual
information) and 1 (perfect correlation). In this function, mutual
information is normalized by some generalized mean of ``H(labels_true)``
and ``H(labels_pred))``, defined by the `average_method`.

This measure is not adjusted for chance. Therefore
:func:`adjusted_mutual_info_score` might be preferred.

This metric is independent of the absolute values of the labels:
a permutation of the class or cluster label values won't change the
score value in any way.

This metric is furthermore symmetric: switching ``label_true`` with
``label_pred`` will return the same score value. This can be useful to
measure the agreement of two independent label assignments strategies
on the same dataset when the real ground truth is not known.

Read more in the :ref:`User Guide <mutual_info_score>`.

Parameters
----------
labels_true : int array-like of shape (n_samples,)
    A clustering of the data into disjoint subsets.

labels_pred : int array-like of shape (n_samples,)
    A clustering of the data into disjoint subsets.

average_method : {'min', 'geometric', 'arithmetic', 'max'}, default='arithmetic'
    How to compute the normalizer in the denominator.

    .. versionadded:: 0.20

    .. versionchanged:: 0.22
       The default value of ``average_method`` changed from 'geometric' to
       'arithmetic'.

Returns
-------
nmi : float
   Score between 0.0 and 1.0 in normalized nats (based on the natural
   logarithm). 1.0 stands for perfectly complete labeling.

See Also
--------
v_measure_score : V-Measure (NMI with arithmetic mean option).
adjusted_rand_score : Adjusted Rand Index.
adjusted_mutual_info_score : Adjusted Mutual Information (adjusted
    against chance).

Examples
--------

Perfect labelings are both homogeneous and complete, hence have
score 1.0::

  >>> from sklearn.metrics.cluster import normalized_mutual_info_score
  >>> normalized_mutual_info_score([0, 0, 1, 1], [0, 0, 1, 1])
  1.0
  >>> normalized_mutual_info_score([0, 0, 1, 1], [1, 1, 0, 0])
  1.0

If classes members ar
```

## Quick recipe

```python
import sklearn.metrics as _m
score = _m.normalized_mutual_info_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.