Six points have true classes A,A,A,B,B,B (points 1–6) and a clustering puts points {1,2} in cluster 1 and {3,4,5,6} 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 =a+d(n2), where a is the number of pairs in the same class and the same cluster and d is the number in different classes and different clusters. Purity =1n∑clustersmax⁡class∣cluster∩class∣.

Steps

  1. There are (62)=15 pairs.
  2. Same class and same cluster (a): (1,2), (4,5), (4,6), (5,6), so a=4.
  3. Same class but different clusters: (1,3) and (2,3), so 2 pairs. Same cluster but different classes: (3,4), (3,5), (3,6), so 3 pairs. Different class and different cluster (d): 15−4−2−3=6.
  4. Rand index =(4+6)/15=2/3≈0.667.
  5. Purity: cluster 1 ={1,2} has majority class A with 2 points. Cluster 2 ={3,4,5,6} has classes A,B,B,B, majority B with 3 points. Purity =(2+3)/6=5/6≈0.833.
  6. 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

How long your answer should be

Half a page; 3–4 minutes.

Last checked on 4 December 2026.

Read this

Previous in Unsupervised learning: Take the 1-D points {1,2,3,10,11,25} with k=2 and absolute-difference distance. Starting from medoids {1,11}, compute the total cost, then the cost after swapping medoid 1 with the non-medoid 2. Does PAM accept the swap, and is {2,11} optimal?
Next in Unsupervised learning: Three 1-D clusters are C1={1,3}, C2={7,9,11} and C3={20,24}. Using the Euclidean distance, compute the Davies–Bouldin index. Is a larger or smaller value better?