/avcmnn

投票+互信息优化参数=聚类算法

Primary LanguagePython

VCMNN and adaptive VCMNN (i.e., AVCMNN) algorithms implemented in python

This project is implemented in python version of An adaptive mutual K-nearest neighbors clustering algorithm based on maximizing mutual information .

Install

The code is written in python, you can access it as follows:

git clone https://github.com/HegemonyTao/avcmnn-python.git
cd avcmnn-python
python -m pip install --user -r requirements.txt

Usage

You can directly run the main function in the root directory to obtain the Adjusted Rand Index (ARI) and Normalized Mutual Information (NMI) of VCMNN and AVCMNN algorithms on the iris dataset. Note that the AVCMNN algorithm may run slowly

cd avcmnn-python
python main.py

Alternatively, you can use it in the root directory by following the steps below:

Import package and database

from model.VCMNN import VCMNN
from model.AVCMNN import AVCMNN
from tools.RandIndex import RandIndex
from database import Database
from tools.utils import *
from sklearn.metrics import normalized_mutual_info_score as nmi
X,y=Database.loadIris()
y=flatten(y)

Clustering with VCMNN

vcmnnIdx=VCMNN(X,25,3)#Recommended value, can be set by yourself
AR1, RI1, MI1, HI1=RandIndex(vcmnnIdx,y)
#Calculate ARI and NMI
NMI1=nmi(vcmnnIdx,y)
print('VCMNN result:ARI={},NMI={}'.format(AR1,NMI1))

Clustering with AVCMNN

avcmnIdx,parameters=AVCMNN(X)
AR2, RI2, MI2, HI2=RandIndex(avcmnIdx,y)
NMI2=nmi(avcmnIdx,y)
print('AVCMNN result:ARI={},NMI={}'.format(AR2,NMI2))

Recommended parameters for different data sets

Datasets k num
Iris 25 3
Heart 31 2
Glass 69 6
Sonar 32 2

Comparison with the algorithm performance in the paper

Datasets KPI VCMNN(paper) AVCMNN(paper) VCMNN(exp) AVCMNN(exp)
Iris ARI 1 1 1 0.9609
NMI 1 1 1 0.953
Heart ARI 0.3085 0.1723 0.5899 0.2739
NMI 0.2661 0.2515 0.4866 0.2563
Glass ARI 0.6757 0.3477 0.6882 0.2414
NMI 0.7587 0.5998 0.7636 0.4131
Sonar ARI 0.3186 0.2876 0.297 0.0084
NMI 0.3732 0.3705 0.32493 0.015