How do you pick the number of groups, and why did one column take over?
Lesson 17.3 · How Many Groups?
Felix · Rosa
Tempo: 60 to 200. Energy: 0 to 1. Guess which one the distance cares about.
Felix switches the map to tempo and energy and the clusters turn into vertical stripes.
Tempo runs from 60 to 200 and energy from 0 to 1, so tempo is the only thing the distance formula can see.
Then Rosa asks the question k-means can’t answer: why three groups? Why not five?
The short answer
Choosing k, and scaling: K-means needs to be told how many groups to find, and it will find that many whether or not they exist. It also measures distance in raw units, so a feature with big numbers dominates. Scaling every feature to the same range first is not optional. Choosing k is a judgment, backed by a few tools.
Try it yourself
Slide the number of groups and watch the map re-cluster. Then flip “same scale” on and see what tempo was hiding.
What you just did has a name
Choosing k, and scaling
K-means needs to be told how many groups to find, and it will find that many whether or not they exist.
It also measures distance in raw units, so a feature with big numbers dominates.
Scaling every feature to the same range first is not optional. Choosing k is a judgment, backed by a few tools.
A few more things
Scale first, always
Tempo in beats per minute swamps energy on a 0-to-1 scale by a factor of a hundred. Standardize both (subtract the mean, divide by the spread) and they get an equal vote. Module 5’s cleaning rule, one more time.
K is a knob, not a discovery
Ask for five groups and you get five, even in a perfectly even cloud. The groups are only as real as the gaps between them. Try several values and see which ones stay stable when the random start changes.
Diminishing returns
Going from one group to two tightens things a lot. Two to three, a bit. Six to seven, barely. Plot that tightness against k and look for the bend, the point where more groups stop buying much. That bend is a common way to pick.
Go deeper
The longer version, if you want it.
The elbow and the silhouette
The “bend” is called the elbow method: plot total within-cluster distance against k and pick the k where the curve flattens. It’s rough, and sometimes there’s no clear elbow. The silhouette score is more formal: for each point, compare how close it is to its own cluster versus the next nearest cluster, averaged over all points. Higher is better, and the k with the highest silhouette is a defensible choice.
Neither replaces judgment. If the elbow says four and the four groups have no meaning a person can name, three meaningful groups are better. Module 17.4 is about the naming.
Quick check
You cluster players by height in centimeters and by free-throw rate as a decimal from 0 to 1. Before running k-means, what has to happen?
Let’s take it slower
K-means has two knobs you set yourself, and it won’t set either one for you. The first knob is k, and the machine always produces exactly that many groups, even from a cloud with no groups in it, so you try a few values and keep the ones that hold up. The second knob is scale. Distance is measured in whatever units you hand over, so a column counted in hundreds shouts and a column between 0 and 1 whispers. Put every column on the same footing first, then turn the k knob on purpose.
More examples
Grouping houses for sale
Cluster listings by price in dollars and number of bedrooms and you get groups sorted purely by price, because 350,000 swamps 3. Scale both to the same range and the bedroom count finally gets a say. Same data, honest groups.
How many friend groups
Ask a clustering tool for eight friend groups in a class of 25 and it hands you eight, some with two people who barely know each other. Ask for two and it splits along whatever line is biggest. The number of groups is your call, and a bad call still gets an answer.
Back to the question
So how many vibes?
Show the answer
With scaling on, three groups stay stable and four splits one of them into two nearly identical halves. Three it is. And the vertical stripes were never vibes. They were tempo shouting over everything else, until Felix put it on the same scale as energy.
One last question
Felix explains k-means settings to Ashley. Trust him?
“K-means figures out how many groups there are on its own.”
“If one feature has much bigger numbers, it dominates the distance unless you scale.”
“Pick the k where adding another group stops tightening things much.”
Talk Card
Talk Card · 17.3
Clustering won’t tell you how many groups there are, and it can’t compare tempo to energy until both are on the same scale. Scale first, then choose k on purpose.
Data to AI · pettigrewlab.com/learn

