← Lessons

quiz vs the machine

Silver1080

Machine Learning

The Elbow Method

Choosing the number of clusters by looking for a bend in the error curve.

3 min read · intro · beat Silver to climb

The Elbow Method

K means needs a value of k, but real data rarely tells you directly how many clusters to use. The elbow method is a simple visual heuristic for picking k.

How it works

We run k means for a range of k values, such as one through ten, and record the within cluster sum of squares for each. This quantity is also called the inertia.

  • For small k the inertia is large because few centers cover many points.
  • As k grows the inertia falls because clusters get tighter.
  • At k equal to the number of points the inertia reaches zero.

Finding the elbow

If you plot inertia against k, the curve drops steeply and then flattens. The elbow is the point where extra clusters stop buying much improvement. That bend is a reasonable choice for k.

Cautions

  • The elbow can be ambiguous when the curve bends gently.
  • It only measures compactness, not whether clusters are meaningful.
  • Pairing it with the silhouette score gives a more confident answer.

Key idea

The elbow method picks k where the inertia curve bends from steep to flat, signaling diminishing returns from more clusters.

Check yourself

Answer to earn rating on the learn ladder.

1. What quantity does the elbow method plot against k?

2. What does the elbow point indicate?