Six points have true classes (points 1–6) and a clustering puts points in cluster 1 and in cluster 2. Compute the Rand index and the purity. Why is the Rand index alone not enough?
Unsupervised learning, Cluster evaluation
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can count agreeing pairs for the Rand index and majority labels for purity, and know their limits.
Key idea
Rand index , where is the number of pairs in the same class and the same cluster and is the number in different classes and different clusters. Purity .
Steps
- There are pairs.
- Same class and same cluster (): , , , , so .
- Same class but different clusters: and , so 2 pairs. Same cluster but different classes: , , , so 3 pairs. Different class and different cluster (): .
- Rand index .
- Purity: cluster 1 has majority class with 2 points. Cluster 2 has classes , majority with 3 points. Purity .
- Limits: the Rand index is not zero for random clusterings (the adjusted Rand index corrects for chance). Purity is trivially 1 if every point is its own cluster, so it cannot be used to compare different numbers of clusters.
Common mistakes
- Counting ordered pairs, or using instead of as the denominator.
- Forgetting the "different class and different cluster" pairs. They also count as agreement.
- Believing a high purity means a good clustering without looking at the number of clusters.
How long your answer should be
Half a page; 3–4 minutes.
Last checked on 4 December 2026.
Read this
- scikit-learn user guide: clustering: The "Clustering performance evaluation" section defines the Rand index and the adjusted Rand index by pair counting, and explains why chance correction is needed.
Previous in Unsupervised learning: Take the 1-D points with and absolute-difference distance. Starting from medoids , compute the total cost, then the cost after swapping medoid 1 with the non-medoid 2. Does PAM accept the swap, and is optimal?
Next in Unsupervised learning: Three 1-D clusters are , and . Using the Euclidean distance, compute the Davies–Bouldin index. Is a larger or smaller value better?