Exam SRM · Unsupervised Learning Techniques · Free Lesson

K-Means and Hierarchical Clustering

Free SOA Exam SRM (Statistics for Risk Modeling) lesson in Unsupervised Learning Techniques. 25 min read, ~3,807 words.

You hand the algorithm unlabeled customer data and ask it to find groups. K-means wants you to declare the number of groups up front. Hierarchical clustering builds every possible grouping at once and lets you cut later.

You fix KK, the target number of clusters, then iterate:

The objective is to minimize within-cluster sum of squares (WCSS):

WCSS=∑k=1K∑i∈Ck∥xi−μk∥2\text{WCSS} = \sum_{k=1}^{K} \sum_{i \in C_k} \| x_i - \mu_k \|^2

KEY: Each iteration weakly decreases WCSS, so the algorithm converges. But it converges to a local minimum, not the global one. Re-run with multiple random starts and keep the lowest WCSS.

Two within-cluster conventions. WCSS sums squared distances to each centroid and is the quantity R's kmeans reports as tot.withinss.

Read the full lesson, free →
Worked examples and practice. Free with a free account, no card.

Common mistakes

Bottom line

Exam shortcut

If the question fixes K and asks you to iterate centroids, it is K-means. If it mentions a dendrogram or linkage, it is hierarchical. The word "chaining" almost always points to single linkage. With tens of thousands of rows and both methods offered, pick K-means on complexity alone.

The full lesson (about 3,807 words, 25 min read) adds 6 worked examples, all 8 common mistakes, a self-check, free in the app.

Learning objectives

Browse all free Exam SRM lessons or jump into free Exam SRM practice questions.