cdlib.evaluation.rmi¶
- cdlib.evaluation.rmi(first_partition: object, second_partition: object, norm_type: str = 'none', logbase: int = 2) MatchingResult¶
This function calculates the Reduced Mutual Information (RMI) between two clusterings.
\[RMI = MI(c1, c2) - \log \frac{Omega(a, b)}{n}\]where MI(c1, c2) is mutual information of the clusterings c1 and c2, and Omega(a, b) is the number of contingency tables with row and column sums equal to a and b.
- Parameters:
first_partition – NodeClustering object
second_partition – NodeClustering object
norm_type – The normalization types are: ‘none’ returns the RMI without a normalization; ‘normalized’ returns the RMI with upper bound equals to 1.
logbase – int, default 2
- 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.rmi(louvain_communities,leiden_communities)
- Reference:
Newman, George T. Cantwell, and Jean-Gabriel Young. Improved mutual information measure for classification and community detection. arXiv:1907.12581, 2019.
Note
The function requires the clusim library to be installed. You can install it via pip: pip install clusim