Lensa ML
Lensa ML

K-Means Clustering

Step 1 of 6

What is Clustering?

Grouping without labels

? unlabeled data ?
POINTS
60
CLUSTERS
3
SEPARATION
4.9

Clustering finds natural groups in unlabeled data. Slide k to change how many true clusters exist, then reveal them.

Step 1 of 6: What is Clustering?

Grouping without labels

? unlabeled data ?
POINTS
60
CLUSTERS
3
SEPARATION
4.9

Clustering finds natural groups in unlabeled data. Slide k to change how many true clusters exist, then reveal them.

Step 2 of 6: How K-Means Works

The algorithm step by step

k = 3 clusters to find
PHASE
1/6
K
3

We have unlabeled data and want to find k=3 clusters. The algorithm needs a way to group these points automatically.

Step 3 of 6: Assignment Step

Color by nearest centroid

Iteration: 0
ITERATION
0
REASSIGNED
60
INERTIA
734.1
LARGEST
24

Each point is assigned to the nearest centroid — creating Voronoi-like regions. Press Play or drag the slider.

Step 4 of 6: Update Step

Move centroids to their means

Iteration: 0
ITERATION
0
MAX DISP
INERTIA
734.1
% CHANGE
0.0%

Centroids move to the mean of their assigned points — then we reassign. Watch the dashed arrows show displacement.

Step 5 of 6: Convergence

When assignments stop changing

Iteration: 0
IterationInertia051015
ITERATION
0
INERTIA
734.1
Δ INERTIA
CONVERGED?
No

K-means converges when no points change their assignment — typically in 5-15 iterations. Watch inertia drop.

Step 6 of 6: The Elbow Method

Choosing the right k

k (clusters)Inertia12345678910elbow
K
3
INERTIA
84.8
Δ INERTIA
306.3
SUGGESTED K
3

The elbow! At k=3, adding more clusters gives diminishing returns. This is usually the best choice.