There's more…

The purpose of the algorithm is to locate k centroids, one for each cluster. The position of each centroid is of particular importance as different positions cause different results. The best choice is to put them as far apart as possible from each other. When this is done, you must associate each object with the nearest centroid. In this way, we will get a first grouping. After finishing the first cycle, we go to the next one by recalculating the new k centroids as the cluster's barycenter using the previous one. Once you locate these new k centroids, you need to make a new connection between the same dataset and the new closest centroid. At the end of these operations, a new cycle is performed. Due to this cycle, we can note that the k centroids change their position step by step until they are modified. So, the centroid no longer moves.