What Are the Evaluation Methods Used in Clustering?

Comparing Clustering Reliability Using Silhouette Coefficient Across Datasets
Title: Comparing Clustering Reliability Using Silhouette Coefficient Across Datasets
Source: Statistical power for cluster analysis by BMC Bioinformatics

Introduction

Clustering is a fundamental technique in unsupervised learning, widely used to discover patterns in unlabeled data. However, clustering does not come with a predefined notion of correctness. As a result, evaluating clustering results is significantly more nuanced than computing accuracy or F1-score. A good clustering technique depends not only on the algorithm used, but also on the geometry of the data, the presence or absence of ground truth labels, and the purpose for which the clusters are being used.

Why Is Clustering Evaluation Challenging?

In supervised learning, evaluation is relatively straightforward: predictions are compared against known labels. In clustering, however, labels are either absent or ambiguous. Multiple clusterings of the same dataset may all be reasonable, even if they differ significantly.

Several factors cause these difficulties:

  • Label permutation: Cluster labels are arbitrary; swapping labels does not change the clustering.
  • Multiple valid structures: Data may contain hierarchical, overlapping, or multi-scale clusters.
  • Algorithmic assumptions: Different algorithms impose different structural biases, like spherical vs density-based clusters.
  • Task dependence: A clustering that is useful for visualization may not be ideal for downstream prediction.

Because of these challenges, clustering evaluation metrics are typically grouped into external and internal approaches:

clustering evaluation methods
Title: Clustering Evaluation Methods
Source: AIML.com Research
  • External Evaluation: Used when ground truth labels are available. Measures agreement between clustering assignments and true class labels.

  • Internal Evaluation: Used when no ground truth is available. Evaluates clustering quality based solely on the data and the resulting cluster structure.

External Evaluation Metrics

Let’s begin with understanding the External Evaluation:

1. Rand Index and Adjusted Rand Index:

The Rand Index (RI) measures the proportion of sample pairs on which the clustering and ground truth agree.

$$RI=\frac{TP+TN}{TP+FP+FN+TN}$$

Where,

$TP$ (True Positives) is the number of data point pairs that belong to the same true class and are assigned to the same cluster.

$TN$ (True Negatives) stands for the number of data point pairs that belong to different true classes and are assigned to different clusters.

$FP$ (False Positives) is the number of data point pairs that belong to different true classes but are assigned to the same cluster.

$FN$ (False Negatives) is the number of data point pairs that belong to the same true class but are assigned to different clusters.

The Rand Index (RI) evaluates clustering by looking at pairs of data points and checking whether each pair is placed together or apart in both the true labels and the predicted clusters. If most pairs are treated the same way in both, the RI score is high. This makes RI easy to understand and interpret, with values ranging from zero to one. 

However, RI has an important limitation: it does not consider that some agreement between clusterings can happen by chance, so even a random clustering can receive a relatively high score. To overcome this, the Adjusted Rand Index (ARI) modifies the Rand Index by correcting for random agreement. As a result, ARI assigns a score close to zero to random clusterings, while a perfectly matching clustering receives a score of one, making ARI a more reliable measure in practice.

When to use:

  • Comparing clustering results against known labels.
  • Benchmarking algorithms on labeled datasets.

Let’s implement RI and ARI using sklearn:

2. Mutual Information-Based Scores

Mutual Information (MI) quantifies the amount of information shared between the true labels and cluster assignments.

Contingency matrix for Mutual Information
Title: Contingency matrix for Mutual Information
     Source: AIML.com Research
$$\text{MI}(U, V) = \sum_{i,j} \frac{N_{ij}}{N} \log \left( \frac{N_{ij} \cdot N}{N_{i\cdot} N_{\cdot j}} \right)$$

Where,

$U$: Set of true classes.
$V$: Set of predicted clusters.
$N$: Total number of data points.

Nij​: Number of data points belonging to true class i and assigned to cluster $j$.
Ni⋅: Total number of data points belonging to true class $i$.
N⋅j: Total number of data points assigned to cluster $j$.

Mutual Information (MI) measures how much information about the true class labels is contained in the predicted cluster assignments. A higher MI value means that knowing the cluster label reduces uncertainty about the true label. This makes MI useful even when the number of clusters does not match the number of classes. 

However, raw MI has two important limitations: it is unbounded, so its absolute value is difficult to interpret, and it tends to increase as the number of clusters grows, even if the clustering quality does not actually improve. Because of these issues, normalized and chance-corrected variants such as Normalized Mutual Information (NMI) and Adjusted Mutual Information (AMI) are generally preferred, as they provide more interpretable and fair comparisons across different clustering results.

When to use:

  • Comparing clusterings with different numbers of clusters
  • When information-theoretic interpretation is desired

Let’s implement MI, NMI, and AMI using sklearn:

3. Homogeneity, Completeness, and V-Measure

Chart showing clustering performance metrics
Title: Clustering Performance Metrics.
Source: Article by Bioinformatics on Research gate

Homogeneity, completeness, and V-measure are entropy-based external evaluation metrics that assess clustering quality by comparing predicted clusters with true class labels. Together, they explain how pure clusters are, how well classes are grouped, and how these two aspects balance each other. Each metric can be directly understood from its mathematical formulation.

Homogeneity measures whether each cluster contains data points from only one true class. A clustering is perfectly homogeneous if no cluster mixes samples from different classes.

$$h = 1 – \frac{H(U|V)}{H(U)}$$

Where,

$U$ is the random variable representing the true class labels of the data points.
$V$ is the random variable representing the predicted cluster labels assigned by the clustering algorithm.
$H(U)$ stands for the entropy of the true class label distribution, measuring the uncertainty associated with the class labels before observing any cluster assignments.
$H(U|V)$ is the conditional entropy of the true class labels given the predicted cluster labels, measuring the remaining uncertainty in the true class labels after the cluster assignment is known.

If each cluster contains samples from only one class, the uncertainty becomes zero, making homogeneity equal to one. As clusters begin to mix multiple classes, the conditional entropy increases, causing the homogeneity score to decrease. In practice, a high homogeneity score indicates that clusters are pure, but it does not guarantee that all samples of a class are grouped.

Completeness is defined as:

$$c = 1 – \frac{H(V|U)}{H(V)}$$

Here,

$U$ is the random variable representing the true class labels of the data points.
$V$ is the random variable representing the predicted cluster labels assigned by the clustering algorithm.
$H(V)$ is the entropy of the predicted cluster label distribution, measuring the uncertainty associated with cluster assignments before considering the true class labels.
$H(V|U)$ stands for the conditional entropy of the predicted cluster labels given the true class labels, measuring the remaining uncertainty in cluster assignments after the true class is known.

Completeness measures whether all samples of a given true class are assigned to the same cluster. If all samples of a class fall into a single cluster, this uncertainty is zero, and completeness reaches one. When a class is fragmented across multiple clusters, the conditional entropy increases and the completeness score drops. Completeness, therefore, penalizes over-splitting, but it does not account for impurity within clusters.

V-measure provides a single score that balances homogeneity and completeness by taking their harmonic mean:

$$V = 2 \cdot \frac{h \cdot c}{h + c}$$

Here, $h$ is the homogeneity score and c is the completeness score.

Because it uses the harmonic mean, V-measure is high only when both homogeneity and completeness are high. If either metric is low, the V-measure decreases significantly. This makes V-measure a useful overall summary of clustering quality, while still encouraging inspection of homogeneity and completeness individually. In practice, V-measure is especially helpful when you want a single interpretable score but still need insight into whether clustering errors are due to class mixing or class splitting.

When to use:

  • Understanding whether errors are due to over-splitting or over-merging
  • Interpretable diagnostics beyond a single score.

Let’s implement using sklearn:

4. Fowlkes-Mallows Score

The Fowlkes-Mallows Index (FMI) evaluates clustering quality by examining pairs of data points and computing the geometric mean of pairwise precision and recall.

$$FMI=\sqrt{\frac{TP}{TP+FP} \cdot \frac{TP}{TP+FN}}$$

In this formula, $TP$ (True Positives) is the number of data point pairs that belong to the same true class and are assigned to the same cluster.

$TN$ (True Negatives) stands for the number of data point pairs that belong to different true classes and are assigned to different clusters. 

$FP$ (False Positives) is the number of data point pairs that belong to different true classes but are assigned to the same cluster.

$FN$ (False Negatives) is the number of data point pairs that belong to the same true class but are assigned to different clusters.

This formulation ensures that a clustering scores highly only when it correctly groups together points that truly belong to the same class while avoiding grouping points from different classes. Because it balances precision and recall at the pair level, FMI is relatively robust to class imbalance compared to some other external metrics. However, FMI relies on pairwise comparisons between data points, which can become computationally expensive for large datasets, and its pair-based interpretation may be less intuitive for readers who are more familiar with class-level or cluster-level evaluation metrics.

When to use:

  • Pairwise clustering evaluation
  • Situations where precision–recall balance is important

FMI can be implemented using sklearn as follows:

Internal Evaluation Metrics

Now, let’s move on to Internal Evaluation Metrics, where there is no ground truth.

Internal metrics evaluate clustering quality using only the data and the resulting cluster assignments. These are the most commonly used metrics in real-world applications.

1. Silhouette Coefficient

The Silhouette Coefficient measures how well a data point fits within its assigned cluster compared to how close it is to other clusters. For a sample i:

$$s(i) = \frac{b(i) – a(i)}{\max(a(i), b(i))}$$

where:

$a(i)$ = average intra-cluster distance

$b(i)$ = minimum average distance to another cluster

max ${a(i),b(i)}$ = A normalization term ensuring that the silhouette score is bounded between −1 and 1.

Silhouette Score
Title: Silhouette Score
Source: AIML.com Research

For each sample, it compares the average distance to points in the same cluster with the average distance to points in the nearest neighboring cluster, producing a value that reflects how confidently the point has been clustered. Because it relies only on distances between data points, the Silhouette Coefficient does not require ground truth labels and can be applied in fully unsupervised settings. It also provides both a global score for the entire clustering and individual scores for each data point, making it useful for diagnosing problematic regions and for selecting an appropriate number of clusters. However, the Silhouette Coefficient implicitly assumes convex and well-separated clusters, which means it can give misleading results for datasets with non-spherical cluster shapes or clusters that differ significantly in density.

When to use:

  • Choosing the number of clusters.
  • Comparing clusterings on the same dataset.

Let’s implement Silhouette Score in sklearn:

2. Calinski-Harabasz Index

Graph of Calinski-Harabasz index for k-means clustering using Elbow criterion
Title: Calinski-Harabasz index for k-means clustering using Elbow criterion
Source: Data Mining in Client-Oriented Businesses

The Calinski-Harabasz Index evaluates clustering quality by measuring the ratio of between-cluster dispersion to within-cluster dispersion, effectively comparing how far apart cluster centers are relative to how tightly data points are grouped within each cluster.

$$\text{CH} = \frac{\text{Tr}(B_k)}{\text{Tr}(W_k)} \cdot \frac{n – k}{k – 1}$$

In this formula, k is the number of clusters produced by the clustering algorithm.
Bk = The between-cluster dispersion matrix, which measures how far cluster centers are from the overall data mean.
Wk = The within-cluster dispersion matrix, which measures how spread out data points are within each cluster.
$Tr⁡(⋅)$ = The trace operator, defined as the sum of the diagonal elements of a matrix, used here to reduce dispersion matrices to scalar values.

A higher value indicates that clusters are both well separated from one another and internally compact. This index is computationally efficient, which makes it suitable for large datasets, and it works particularly well for centroid-based clustering methods such as K-Means. However, the Calinski-Harabasz Index assumes that clusters are compact and clearly separated, so it may produce unreliable or misleading results when clusters have irregular shapes or complex structures.

When to use:

  • Centroid-based methods like K-Means.
  • Fast evaluation for large datasets

Sklearn implementation for Calinski-Harabasz Index:

3. Davies-Bouldin Index

The Davies–Bouldin Index (DBI) evaluates clustering quality by measuring the average similarity between each cluster and its most similar neighboring cluster, where similarity is defined in terms of cluster spread relative to the distance between cluster centers.

$$\text{DBI} = \frac{1}{k} \sum_{i=1}^{k} \max_{j \neq i} \left( \frac{s_i + s_j}{d_{ij}} \right)$$

Here, i,j are indices representing two different clusters, where i≠j.

si is the within-cluster dispersion of cluster i, defined as the average distance between all data points in cluster i and the centroid of cluster i.
sj is the within-cluster dispersion of cluster j, defined analogously.
dij stands for the between-cluster separation, defined as the distance between the centroids of clusters i and j.
max⁡j≠i is for selects the cluster j that is most similar to cluster i according to the dispersion-to-separation ratio.

Lower DBI values indicate better clustering, as they correspond to clusters that are compact and well separated. The index is fast to compute and makes it easy to compare different clustering models on the same dataset. However, DBI is sensitive to noise and outliers, which can inflate cluster spread and degrade the score, and it implicitly assumes that clusters have similar variance and density, making it less reliable for datasets with highly irregular or uneven cluster structures.

When to use:

  • Comparing cluster compactness and separation.
  • Fast relative comparison across models

Code snippet for implementing Davies-Bouldin Index in sklearn:

Conclusion:

Clustering evaluation is inherently multifaceted, and no single metric can fully capture the quality of a clustering result across all datasets and use cases. External metrics such as ARI, Mutual Information-based scores, and Fowlkes-Mallows are valuable when ground truth labels are available, as they quantify how closely clusters align with known classes. Internal metrics like the Silhouette Coefficient, Calinski-Harabasz Index, and Davies-Bouldin Index are essential in real-world scenarios where labels are absent, providing insight into cluster compactness and separation based solely on the data geometry. Each metric reflects specific assumptions about cluster structure, shape, and density, which means their scores must be interpreted in context rather than in isolation.

Video Explanations

  • This video, “Clustering 9: Evaluating Clustering Systems” by Victor Lavrenko, explains how to evaluate clustering results and why measuring clustering quality is inherently difficult. It introduces the concepts of extrinsic evaluation and intrinsic evaluation, clarifying when and why each approach is used (Runtime: 6 mins).
YouTube video
Evaluating clustering systems by Victor Lavrenko
  • This video, “Understanding Clustering Results” by Mitchell R. Wenger, explains how to interpret and make sense of clustering outputs, particularly in the context of exploratory data analysis. It focuses on developing intuition about what clusters reveal and how to reason about their structure and meaning (Runtime: 10 mins).
YouTube video
Understanding Clustering Results” by Mitchell R. Wenger

Author

  • Master’s student in Computer Science with a strong focus on machine learning, data science, and AI systems.
    Passionate about building and researching intelligent, data-driven solutions, with hands-on experience in ML research, NLP pipelines, and open data ecosystems.
    Enjoys continuous learning and exploring new ideas in AI and data science.

Help us improve this post by suggesting in comments below:

– modifications to the text, and infographics
– video resources that offer clear explanations for this question
– code snippets and case studies relevant to this concept
– online blogs, and research publications that are a “must read” on this topic

Leave the first comment

Partner Ad
Find out all the ways that you can
Contribute