No labels needed. Drop K centroids into unlabeled data, assign each point to the nearest one, move centroids to the mean — repeat until stable.
K-Means is the most widely used clustering algorithm. It partitions data into K groups by iterating two simple steps: assign each point to its nearest centroid, then move each centroid to the mean of its assigned points. It repeats until centroids stop moving — convergence. The algorithm is fast, simple, and scales to millions of points.
White spheres are unlabeled data. Step through the assign → update loop and watch clusters emerge from nothing.
Three steps. Two of them alternate until nothing changes.
Place K centroids at random positions in the data space. The choice of starting positions affects which solution is found — K-Means++ improves this with a smarter spread.
For every data point, compute the distance to each centroid and assign the point to the closest one. This partitions the space into Voronoi regions.
Move each centroid to the mean (average) of all points currently assigned to it. Points may change clusters in the next assign step because centroids moved.
Repeat assign and update until no point changes cluster between iterations. The algorithm is guaranteed to converge — but not necessarily to the global optimum.