snf.metrics.nmi

snf.metrics.nmi(labels)[source]

Calculates normalized mutual information for all combinations of labels

Uses sklearn.metrics.v_measure_score() for calculation; refer to that codebase for information on algorithm.

Parameters:labels (m-length list of (N,) array_like) – List of label arrays
Returns:nmi – NMI score for all combinations of labels
Return type:(m x m) np.ndarray

Examples

>>> import numpy as np
>>> label1 = np.array([1, 1, 1, 2, 2, 2])
>>> label2 = np.array([1, 1, 2, 2, 2, 2])
>>> from snf import metrics
>>> metrics.nmi([label1, label2])
array([[1.        , 0.47870397],
       [0.47870397, 1.        ]])