Cluster Analysis — Definition, Formula & Example
Cluster analysis, also called clustering, is a method that sorts data points into groups so that points in the same group resemble each other more than they resemble points in other groups. No one tells the method what the groups are ahead of time. It finds them from the data alone.
Given observations and a dissimilarity measure (often Euclidean distance), cluster analysis seeks a partition of the data into disjoint, nonempty subsets that keeps within-cluster dissimilarity small and between-cluster dissimilarity large. It is an unsupervised learning method because the observations carry no class labels. Partitioning methods such as k-means fix in advance. Hierarchical methods instead build a nested sequence of partitions, displayed as a dendrogram.
Key Formula
Where:
- = within-cluster sum of squares, the quantity k-means tries to minimize
- = number of clusters
- = the set of points assigned to cluster j
- = centroid (mean point) of cluster j
- = squared Euclidean distance from point to its cluster's centroid
Worked Example
Problem: Six students report (hours studying per week, hours gaming per week): A(1, 8), B(2, 9), C(3, 7), D(8, 2), E(9, 3), F(10, 1). Run k-means with k = 2, using A and F as the starting centroids.
Step 1: Assign each point to the nearer centroid using squared distance. For example, C is much closer to A(1, 8) than to F(10, 1). A, B, and C join cluster 1. D, E, and F join cluster 2.
Step 2: Update each centroid to the mean of its cluster's points.
Step 3: Reassign the points with the new centroids. Every point stays put. For example, D is 72 squared units from (2, 8) but only 1 from (9, 2). Since no point moved, the algorithm has converged. Compute W.
Answer: The two clusters are {A, B, C} (study less, game more) with centroid (2, 8) and {D, E, F} (study more, game less) with centroid (9, 2). The within-cluster sum of squares is W = 8.
Why It Matters
Clustering is a core topic in machine learning and data science courses. Businesses use it for customer segmentation, biologists use it to group genes with similar expression patterns, and image software uses it to compress colors. It is often the first step when you have a large data set and no labels.
Common Mistakes
Mistake: Clustering on variables measured in very different units, such as income in dollars and age in years, without rescaling them.
Correction: Distance-based methods let the variable with the largest numbers dominate. Standardize each variable first, for example by converting to z-scores, so that each one contributes fairly.
