← Back to Glossary

K-Means Clustering

A method of vector quantization that aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean.

How it works

K-Means starts by randomly placing k centroids in the data space. It then alternates between two steps: assignment (each point is assigned to the nearest centroid) and update (each centroid is moved to the mean of its assigned points). These steps repeat until the assignments no longer change. The algorithm is sensitive to initialisation; K-Means++ improves this by spreading initial centroids apart. The number of clusters k must be chosen in advance, often using techniques like the elbow method.

Why it matters

K-Means is one of the most widely deployed unsupervised learning algorithms due to its simplicity and speed. It is used to segment customers, compress images (vector quantisation), initialise more complex clustering algorithms, and explore the structure of embedding spaces produced by language models. In AI infrastructure, K-Means is also used to cluster training data for quality filtering and to balance data distributions across different topic areas.

Let's talk

Have something worth building?

Newsletter

Stay in the loop

AI tools, tips & tricks — no spam.

Type to start searching...