NMI (standardized mutual information) Python implementation __python

Source: Internet
Author: User
Introduced

NMI is an important measure of community discovery (community detection) in the case of standard Ground-truth, which can objectively evaluate the accuracy of a Community division compared with the standard division. The range of NMI is 0 to 1, the higher the representation the more accurate. The specific principles and examples can refer to this blog: http://www.cnblogs.com/ziqiao/archive/2011/12/13/2286273.html
Because of the previous use, but found in the online off-the-shelf calculation NMI code is basically MATLAB and Java, did not find in Python write. So there is nothing to do today, the above blog in the Matlab implementation method with Python to achieve a bit. It will be used directly in the future. Code

In fact, the code is very simple, is the reference blog directly from Matlab translated into Python, but there are some small pits just.

Directly to the code, and the blog is no different, here to explain the code in the EPS is a very small positive number, in order to prevent the log function parameter is 0.
In order to facilitate the use of Python words can be used directly, and finally with the download address. Results

Using the use cases in your code, you can see that if the output is 0.36456, the result is correct. Download Address

CDNs download
No points can also be github download:
GitHub download Link
Remember to star!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.