K-means Clustering
Interactive Demonstration

"In data mining, k-means clustering is a method of cluster analysis which aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean." - K-means clustering, Wikipedia

Use the 2D demonstration below to experiment with the standard Lloyd's algorithm to develop an intuition for the technique. You can try differently generated data, or select Manual to click in your own data points.

The algorithm is quite simple. At first a random set of cluster centres is initiated. Points are then assigned to their nearest centre. Centres are adjusted to match the centre of all points assigned to them. The assignment and adjustment steps are repeated until the centres no longer move.

K-means Demonstration

Controls


Click and drag circles.
Data Generation
Method:
Points:
Clusters:
constant data cluster size
K-means
Clusters:
show history