Another way to compare a clustering with ground truth is to ask how much knowing one labeling tells you about the other. Mutual information measures that shared information in nats. It is hard to read on its own, because its scale depends on the entropy of each labeling, so normalized mutual information (NMI) divides it by the average of the two entropies. The result lies in [0, 1].
Implement normalized_mutual_information(labels_true, labels_pred) with arithmetic-mean normalization.
1.0.ValueError.Open one at a time. Each gives away a little more than the last.
Reuse the contingency table idea: np.unique(..., return_inverse=True) plus np.add.at.
Only sum over nonzero cells. Filter with p_ij > 0 before taking logs.
No results yet
Run your code to check it against the examples, or submit to run every test.