Holger von Jouanne-Diedrich takes us through an example of how k-means clustering works:
The guiding principles are:
– The distance between data points within clusters should be as small as possible.
– The distance of the centroids (= centres of the clusters) should be as big as possible.Because there are too many possible combinations of all possible clusters comprising all possible data points k-means follows an iterative approach
Click through for a demonstration. I appreciate adding visualizations for intermediate steps in there as well because it gives you an intuitive understanding for what the one-liner function is really doing.