<aside> 💡
k-means is a simple and popular clustering algorithm. It groups data into K clusters by repeatedly assigning points to the nearest cluster center (centroid) and then updating those centroids as the mean of assigned points.
</aside>
Initialize centroids
Assign points to clusters

Update centroids
For each cluster $j$, recompute centroid $μ_j$ as the average (mean) of all points assigned to that cluster. (To find the actual centroid, we iteratively update each cluster center by calculating the mean of all data points currently assigned to that cluster.)
If $n_j$ is the number of points in cluster $j$, then
$$ \mu_j = \frac{1}{n_j}\sum_{i:Z_i=j} X_i $$
Since above equation calculates the centroid of a cluster,

Repeat
