K-means clustering is an important tools in data analytics. It’s actually quite easy once you see it in action.
The K-means algorithm starts by placing K points (centroids) at random locations in space. We then perform the following steps iteratively:
- for each instance, we assign it to a cluster with the nearest centroid, and
- we move each centroid to the mean of the instances assigned to it.
The algorithm continues until no instances change cluster membership.