I wanted to find the normalized mutual information to validate a clustering algorithm, but I've encountered two different values depending on the library I use.
In Python:
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [1, 1, 0, 0, 3, 3]
nmi = metrics.normalized_mutual_info_score(labels_true, labels_pred)
This returns nmi = 0.52954
.
In R:
library(aricode)
labels_true = c(0, 0, 0, 1, 1, 1)
labels_pred = c(1, 1, 0, 0, 3, 3)
nmi = NMI(labels_true,labels_pred)
This returns n = 0.42061
.
Which one should I trust? I don't really know why they are returning different results if there is a closed formula for NMI...