Cluster Purity
Cluster purity is a simple way to ask: “When a clustering algorithm puts items together, how mixed are those groups really?” It gives you a quick sense of whether each discovered cluster mostly contains one known class or whether different classes are tangled together.
What it measuresCluster purity is an external evaluation metric, which means you calculate it only when you have ground-truth labels for comparison. For each cluster, you find the class that appears most often in that cluster, count those correctly aligned items, and then add those counts across all clusters. Dividing by the total number of data points gives the purity score.
- A purity of 1.0 means every cluster contains items from just one class.
- Lower purity means clusters contain more label mixing.
- The metric is easy to interpret: higher means “cleaner” clusters.
Purity is useful because it gives an immediate read on whether clustering matches a real grouping you care about, such as customer segments, document topics, or handwritten digit categories. But it has an important weakness: it rewards making more clusters. If you put every data point in its own cluster, purity becomes perfect, even though the clustering is useless. That means purity should not be trusted by itself when choosing the number of clusters or comparing models with very different cluster counts.
Practical useSuppose you run KMeans in scikit-learn on news articles and compare the clusters to known topic labels like sports, politics, and business. High purity means each cluster is dominated by one topic. In fraud analysis, purity can show whether suspicious transaction clusters align with known fraud types. In practice, people pair purity with metrics like Normalized Mutual Information (NMI) or Adjusted Rand Index (ARI), which penalize trivial clusterings more fairly.
Cluster Purity is an external clustering metric that measures how homogeneous each cluster is with respect to known ground-truth class labels. It is computed by assigning each cluster to its most frequent class and summing those majority counts across clusters, then dividing by the total number of data points. Cluster Purity matters because it gives a simple, interpretable check of how well clustering aligns with real classes, though it can be artificially inflated by creating many small clusters.
Imagine sorting a mixed box of fruit into bowls. If one bowl is almost all apples, that bowl is very pure. If another bowl has apples, oranges, and bananas all mixed together, it has low purity.
Cluster Purity uses that same idea for AI grouping tasks. A cluster is just a group the system made from similar items. Purity checks how “clean” each group is by seeing whether most items in it really belong to the same known category. It matters because it gives a simple way to judge whether the AI’s groups make intuitive sense. High purity means the groups are mostly consistent; low purity means the groups are more mixed up.