K-means algorithm breakdown

The mechanism of the K-means algorithm can be summarized with the following flowchart:

Flowchart of the K-means process

Let's describe the process in more detail:

We start with the unclassified samples and take K elements as the starting centroids. There are also possible simplifications of this algorithm that take the first element in the element list for the sake of brevity.

We then calculate the distances between the samples and the first chosen samples, and so we get the first calculated centroids (or other representative values). You can see in the moving centroids in the illustration a shift toward a more ...

Get Machine Learning for Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.