cdlib.evaluation.rmi

cdlib.evaluation.rmi(first_partition: object, second_partition: object, norm_type: str = 'none', logbase: int = 2) MatchingResult

此函数计算两个聚类之间的简化互信息(RMI)。

\[RMI = MI(c1, c2) - \log \frac{Omega(a, b)}{n}\]

其中 MI(c1, c2) 是聚类 c1 和 c2 的互信息,而 Omega(a, b) 是行和列总和等于 a 和 b 的列联表的数量。

Parameters:
  • first_partition – NodeClustering 对象

  • second_partition – NodeClustering 对象

  • norm_type – 归一化类型有:'none' 返回未归一化的RMI;'normalized' 返回上界等于1的RMI。

  • logbase – int, 默认值 2

Returns:

匹配结果对象

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:

      1. Newman, George T. Cantwell, 和 Jean-Gabriel Young. 改进的互信息度量用于分类和社区检测. arXiv:1907.12581, 2019.

注意

该函数需要安装clusim库。您可以通过pip安装:pip install clusim