K-means is an unsupervised learning algorithm that assigns labels to the data points (clustering) with an iterative optimization that repeats until convergence.

Optimization#
- initialize clusters centers (also called centroids) randomly
- update cluster labels by assigning points to the nearest cluster center
- update cluster centers by setting the center to the mean of the corresponding cluster
Loss function#
Euclidean distance is the metric used to find the nearest centroids.
Pitfalls#
Data scaling like normalization or standardization is recommended since euclidean distance is highly sensitive to the scale of the axis, and a dimension much larger than the other would dominate the distance calculation.