normalized_mutual_information(first_partition: object, second_partition: object) → cdlib.evaluation.comparison.MatchingResult¶
Normalized Mutual Information between two clusterings.
Normalized Mutual Information (NMI) is an 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
sqrt(H(labels_true) * H(labels_pred))
- first_partition – NodeClustering object
- second_partition – NodeClustering object
>>> from cdlib import evaluation, algorithms >>> g = nx.karate_club_graph() >>> louvain_communities = algorithms.louvain(g) >>> leiden_communities = algorithms.leiden(g) >>> evaluation.normalized_mutual_information(louvain_communities,leiden_communities)