Tutorials · Chapter D (4/4) · ~10 min
Clustering
Try it → see it → read → next
Group similar examples without labels, then explain what the groups do and do not mean.
Try yourself
Playground
Cluster playground
Cluster the points, then assign meaning. Don’t mistake a grouping for ground truth.
Recap
What you just did
ClusterPlayground grouped unlabeled points, then tempted you with a permanent label. Clusters are hypotheses to interpret carefully, not ground truth.
Teach
How it works
A k-means-style loop is surprisingly small:
points = [(1, 1), (2, 1), (8, 8), (9, 8)]
centers = [(1, 1), (9, 8)]
# Repeat:
# 1) assign each point to its nearest center
# 2) move each center to the mean of its assigned points
# 3) stop when assignments barely change
- Features place examples on a map
- Distance defines what “similar” means
- Assignment connects each point to a cluster
- Center update makes groups settle
Mental model: clustering arranges a messy drawer into piles; you still have to decide what each pile means.
Use it
When you'd use this
- Finding rough customer or document segments
- Exploring an unlabeled dataset before supervised training
- Grouping embeddings by semantic similarity
Watch out
Watch out
Clusters are not natural facts or fair human categories. Changing feature scales can completely change the groups. Never turn exploratory clusters into sensitive labels without evidence, domain review, and bias checks.
Try next
Try this next
Imagine multiplying one feature by 100. Predict which direction would dominate distance, then normalize it and compare.