k-Means Clustering
- Definition
- K-Means divides data into k clusters by alternating assignment to the nearest center and updating centers to the mean of assigned points. Imagine grouping points by repeatedly putting them into the nearest cluster center until things stabilize. K-Means differs from density-based methods (like DBSCAN) because it assumes spherical clusters and a fixed k, making it fast but less flexible for irregular shapes.

How does it work?
k-Means Clustering models learn from labeled examples: prepare features, choose a model family, train on examples, and validate on held-out data. Pay attention to data preprocessing, class imbalance, and hyperparameter tuning.
Examples
- Customer segmentation — Cluster customers by behaviour for targeted marketing campaigns.
- Color quantization — Reduce image palettes by clustering pixel colours for compression.
- Document clustering — Group similar documents for search indexing and exploratory analysis.
Problems
- Must choose the number of clusters k in advance
- Sensitive to initial centroid placement, leading to different results
- Assumes spherical, similarly-sized clusters, which is often unrealistic
- Sensitive to outliers and unscaled features
- Struggles with non-convex cluster shapes