如何使用规范化互信息来评估python中igraph的重叠社区

时间:2014-04-16 20:48:54

标签: python igraph

鉴于重叠聚类算法的日益普及,特别是在社交网络分析中,需要定量测量来衡量方法的准确性。我需要知道如何使用规范化互信息(NMI,在igraph中提供)来评估python中igraph的重叠社区。

此功能:http://igraph.sourceforge.net/doc/python/

compare_communities(comm1, comm2, method='nmi', remove_none=False)

,其中

method = "nmi"

comm1comm2是重叠聚类对象(http://cneurocvs.rmki.kfki.hu/igraph/doc/python/igraph.clustering.OverlappingClustering-class.html

我试过了:

cl = igraph.Clustering([(0,), (0,), (0,1), (1,), (1,), ()])

但是,它会返回此错误:

Traceback (most recent call last):
      File "multilevel_overlapping.py", line 94, in <module>
        cl = igraph.Clustering([(0,), (0,), (0,1), (1,), (1,), ()])
      File "/usr/lib/python2.7/dist-packages/igraph/clustering.py", line 92, in __init__
        self._len = max(m for m in self._membership if m is not None)+1
TypeError: can only concatenate tuple (not "int") to tuple

另外,试过这个:

cl = igraph.OverlappingClustering([(0,), (0,), (0,1), (1,), (1,), ()])

但是,它会返回此错误:

Traceback (most recent call last):
  File "multilevel_overlapping.py", line 94, in <module>
    cl = igraph.OverlappingClustering([(0,), (0,), (0,1), (1,), (1,), ()])
AttributeError: 'module' object has no attribute 'OverlappingClustering'

有人可以帮我使用NMI功能吗?

1 个答案:

答案 0 :(得分:1)

文档中似乎有拼写错误。您引用的课程称为OverlappingClustering而不是Clustering。因此,试试这个:

 cl = OverlappingClustering([(0,), (0,), (0,1), (1,), (1,), ()])