One of the primary disadvantages of any clustering technique is that it is difficult to evaluate its performance. To tackle this problem, the metric of V-Measure was developed.
The calculation of the V-Measure first requires the calculation of two terms:-
- Homogenity: A perfectly homogenous clustering is one where each cluster has data-points belonging to the same class label. Homogeneity describes the closeness of the clustering algorithm to this perfection.
- Completeness: A perfectly complete clustering is one where all data-points belonging to the same class are clustered into the same cluster. Completeness describes the closeness of the clustering algorithm to this perfection.
Trivial Homogeneity: It is the case when the number of clusters is equal to the number of data points and each point is in exactly one cluster. It is the extreme case when homogeneity is highest while completeness is minimum.
Trivial Completeness: It is the case when all the data points are clustered into one cluster. It is the extreme case when homogeneity is minimum and completeness is maximum.
Assume that each data point in the above diagrams is of the different class label for Trivial Homogeneity and Trivial Completeness.
Note: The term homogeneous is different from completeness in the sense that while talking about homogeneity, the base concept is of the respective cluster which we check whether in each cluster does each data point is of the same class label. While talking about the completeness, the base concept is of the respective class label which we check whether data points of each class label is in the same cluster.
In the above diagram, the clustering is perfectly homogeneous since in each cluster the data points of are of the same class label but it is not complete because not all data points of the same class label belong to the same class label.
In the above diagram, the clustering is perfectly complete because all data points of the same class label belong to the same cluster but it is not homogeneous because the 1st cluster contains data points of many class labels.
Let us assume that there are N data samples, C different class labels, K clusters and number of data-points belonging to the class c and cluster k. Then the homogeneity h is given by the following:-
The completeness c is given by the following:-
Thus the weighted V-Measure is given by the following:-
The factor can be adjusted to favour either the homogeneity or the completeness of the clustering algorithm.
The primary advantage of this evaluation metric is that it is independent of the number of class labels, the number of clusters, the size of the data and the clustering algorithm used and is a very reliable metric.
The following code will demonstrate how to compute the V-Measure of a clustering algorithm. The data used is the Detection of Credit Card Fraud which can be downloaded from Kaggle. The clustering algorithm used is the Variational Bayesian Inference for Gaussian Mixture Model.
Step 1: Importing the required libraries
Step 2: Loading and Cleaning the data
Step 3: Building different clustering models and comparing their V-Measure scores
In this step, 5 different K-Means Clustering Models will be built with each model clustering the data into a different number of clusters.
a) n_clusters = 2
b) n_clusters = 3
c) n_clusters = 4
d) n_clusters = 5
e) n_clusters = 6
Step 4: Visualizing the results and comparing the performances
- DBSCAN Clustering in ML | Density based clustering
- ML | Hierarchical clustering (Agglomerative and Divisive clustering)
- ML | Mean-Shift Clustering
- ML | Spectral Clustering
- ML | K-Medoids clustering with example
- High-Performance Array Operations with Cython | Set 1
- Python2 vs Python3 | Syntax and performance Comparison
- High-Performance Array Operations with Cython | Set 2
- Different Types of Clustering Algorithm
- ML | OPTICS Clustering Explanation
- Clustering in Machine Learning
- ML | Types of Linkages in Clustering
- K means Clustering - Introduction
- Implementing Agglomerative Clustering using Sklearn
- ML | OPTICS Clustering Implementing using Sklearn
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.