cdlib.evaluation.mi

cdlib.evaluation.mi(first_partition: object, second_partition: object) MatchingResult

This function calculates the Mutual Information (MI) between two clusterings.

\[MI = (S(c1) + S(c2) - S(c1, c2))\]

where S(c1) is the Shannon Entropy of the clustering size distribution, S(c1, c2) is the Shannon Entropy of the join clustering size distribution,

Parameters:
  • first_partition – NodeClustering object

  • second_partition – NodeClustering object

Returns:

MatchingResult object

Example:

>>> from cdlib import evaluation, algorithms
>>> import networkx as nx
>>> g = nx.karate_club_graph()
>>> louvain_communities = algorithms.louvain(g)
>>> leiden_communities = algorithms.leiden(g)
>>> evaluation.mi(louvain_communities,leiden_communities)
Reference:

Leon Danon, Albert D ıaz-Guilera, Jordi Duch, and Alex Arenas. Comparing community structure identification. Journal of Statistical Mechanics: Theory and Experiment, 2005(09):P09008–P09008, September 2005.

Note

The function requires the clusim library to be installed. You can install it via pip: pip install clusim