How to use Normalized Mutual Information to evaluate overlapping community from igraph in python

StackOverflow https://stackoverflow.com/questions/23119834

  •  04-07-2023
  •  | 
  •  

Question

Given the increasing popularity of algorithms for overlapping clustering, in particular in social network analysis, quantitative measures are needed to measure the accuracy of a method. I need know how to use Normalized Mutual Information (NMI, available in igraph) to evaluate overlapping community from igraph in python.

This function: http://igraph.sourceforge.net/doc/python/

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

where

method = "nmi"

and comm1 and comm2 is a OverlappingClustering Object (http://cneurocvs.rmki.kfki.hu/igraph/doc/python/igraph.clustering.OverlappingClustering-class.html)

I tried this:

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

But, it returns this error:

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

Also, tried this:

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

But, it returns this error:

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'

Would anyone can help me to use NMI function?

Was it helpful?

Solution

There seems to be a typo in the documentation. The class you're referring to is called OverlappingClustering not Clustering. Therefore try this:

 cl = OverlappingClustering([(0,), (0,), (0,1), (1,), (1,), ()])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top