2.5.2 · D1Unsupervised Learning

Foundations — Choosing K (elbow method, silhouette score)

1,999 words9 min readBack to topic

Before you can read the parent note on Choosing K, you meet a pile of symbols: , , , , , , , , . This page builds each one from nothing, in the order they need each other. A smart 12-year-old should finish able to read every formula on the parent page out loud and know what it means.


1. A data point — the dot on the page

Everything starts with a single piece of data.

The bold letter is a signal: "this is not one number, it is a little bundle of numbers." Each number is called a feature or a coordinate.

Figure — Choosing K (elbow method, silhouette score)

Look at the figure: two features means we can draw each data point as a dot on a flat page, spending along the bottom, frequency up the side. This picture — dots scattered on a plane — is the mental image behind every symbol that follows. Clustering is just: draw loops around dots that huddle together.


2. Distance — how far apart two dots are

To say dots "huddle together" we need to measure the gap between two dots.

The little subscripts and are just name tags for different dots ("dot number ", "dot number "). They are not maths operations — they only tell dots apart.

Figure — Choosing K (elbow method, silhouette score)

WHY straight-line distance and not something fancier? Because on a flat page, "close together" means short ruler-length. This is the ordinary distance from the Pythagorean theorem:

The silhouette score on the parent page uses directly, so this symbol is essential.


3. Norm and squared distance — the symbol

The parent's inertia formula uses . Let's earn every mark.

So is: "make the arrow from the centre to the point , then take its length." Subtracting two points gives the arrow between them; the bars give that arrow's length.

The little on the outside means square that length (multiply it by itself).

Figure — Choosing K (elbow method, silhouette score)

In the figure, each dashed line is one ; the little shaded square hanging off it is that distance squared. Bigger square = bigger penalty.


4. Centroid — the balance point of a cluster,

Bold again → it is a point with coordinates, not a single number. To find it you average the spending of all dots in the cluster (that's its horizontal position) and average their frequency (its vertical position). This is the "mean" the squaring in §3 rewards.


5. A cluster and its size — and

Notice the bars mean two different things depending on what's inside:

  • around an arrow/point → its length.
  • around a set → its count.

Context tells you which. The parent uses in cohesion because when you average distances from a point to its cluster-mates, the point doesn't count itself, so there are neighbours.


6. The summation sign — "add up all of these"

The scariest-looking symbol is the friendliest.

Read it slowly, right to left:

  • — the squared distance from one dot to its centre.
  • — "for every dot in () cluster , do that and add them all together."

The symbol means "is a member of." So the whole thing is: walk through every dot in this cluster, square its distance to the centre, and total them.

A with numbers, like , means "let be , then , ... up to , and add a copy for each." Nested sums (one inside another) just mean do all clusters, and inside each, do all its points — a loop inside a loop.


7. Inertia — one number for "how messy are the clusters"

Now every piece of the inertia formula is defined, so we can read it whole:

This single number is what the elbow method plots against .


8. and — the smallest and biggest of a list

The silhouette formulas use two more words dressed as symbols.

  • In separation, means: look at the average distance to each other cluster, and keep the smallest — the nearest rival cluster. ( = "over all clusters that are not the home cluster ".)
  • In the silhouette coefficient, dividing by keeps the answer between and by dividing by whichever of the two numbers is larger.

9. Cohesion and separation — the silhouette pair

With distance, , size, and in hand, both are now readable:

The silhouette of one dot then just compares the two: Close to home and far from rivals ⇒ near . That's the whole story.


Prerequisite map

Data point x - a dot on the page

Distance d - ruler gap between dots

Norm bars - length of an arrow

Squared distance - penalty that rewards the mean

Centroid mu - average position of a cluster

Cluster C and size C-count

Sum sign - add over all dots

Inertia - one number for messiness

Elbow method

Cohesion a and separation b

min and max - pick smallest or biggest

Silhouette score

Choosing K

The whole page fans into two measuring sticks — inertia for the elbow, silhouette for the fit score — and those two feed the decision of Choosing K. Related methods worth meeting later: K-Means Clustering (which produces the clusters), DBSCAN and Hierarchical Clustering (which need no ), the Gap Statistic (a fancier elbow), and the general idea of Hyperparameter Tuning and Bias-Variance Tradeoff that "picking " is one example of.


Equipment checklist

Cover the right side and answer each; only move on when all reveal correctly.

What does a bold mean (vs a plain )?
A bundle/list of numbers (a point with several features), not a single number.
What do the double bars measure?
The length of the arrow — the distance it spans.
What does compute in words?
The squared straight-line distance from point to the centre .
Why square the distance instead of using it raw?
It punishes far points hard AND makes the mean the distance-minimising centre.
What is ?
The centroid — the average (balance) position of all dots in cluster .
What is the difference between and ?
Bars on an arrow = its length; bars on a set = the count of its members.
Read aloud.
"For every dot in cluster , add up the following."
What does mean?
"Is a member of" — belongs to that set.
What does pick in the separation formula?
The smallest average distance to any cluster other than the home cluster — the nearest rival.
In , what does dividing by achieve?
It keeps the score between and regardless of the distance scale.
What single number does the elbow method plot against ?
Inertia (total within-cluster squared distance).