Skip to content
BENIBIX Learn

k-Means Clustering

AI📈 Machine LearningClassic ML Algorithms

Also known as k-Means, K-Means Algorithm

It splits data into k groups. It moves k centre points until they stop.

Think of it like

Think of it like three ice cream carts on a beach. You place them so no one walks too far.

Example

Emma runs k-means with k set to 4 on her customers' spending. It finds four groups, from rare small spenders to weekly big spenders.

Why it matters

It is one of the simplest and fastest ways to find groups in data that has no labels.

Definition

k-means clustering is a method that splits data into k groups, where k is a number you choose. It starts by dropping k centre points at random. Each example joins the group of its nearest centre. Then each centre moves to the middle of its group. These two steps repeat until the centres stop moving.
The crosses are the k centres. Each dot belongs to the cross nearest to it.

Common mistake

Picking k without thinking. The method always returns k groups, even if the data really has two or ten.

Key takeaways

  1. 1
    You pick k. The number of groups.
  2. 2
    Join the nearest. Each point picks a centre.
  3. 3
    Move and repeat. Until the centres settle.

Compare

Learn it properly