K-Means Clustering & The Elbow Method
K-Means Clustering & The Elbow Method
In modern commerce, treating all customers identically leads to suboptimal marketing returns and high churn. K-Means Clustering is the preeminent unsupervised machine learning algorithm used to partition unlabeled datasets into $K$ distinct, non-overlapping behavioral clusters based on geometric feature proximity.
1. How K-Means Works: The Lloyd-Forgy Algorithm
- 1Initialization: Select $K$ initial centroid coordinates at random (or via K-Means++).
- 2Assignment Step: Assign each data point to its nearest centroid using Euclidean distance:
$$d(x, c_j) = \sqrt{\sum_{i=1}^{p} (x_i - c_{ji})^2}$$
- 1Update Step: Recalculate each centroid as the geometric mean of all data points assigned to it.
- 2Convergence: Repeat steps 2 and 3 until centroids stabilize (inertia stops decreasing).
2. Choosing Optimal $K$: The Elbow Method & Inertia
Because K-Means is unsupervised, there are no ground-truth labels. Analysts use Inertia (Within-Cluster Sum of Squares - WCSS):
$$WCSS = \sum_{k=1}^{K} \sum_{x \in C_k} ||x - \mu_k||^2$$
As $K$ increases, WCSS naturally drops towards zero (if $K=N$, WCSS=0). The Elbow Method finds the point of diminishing marginal returns:
3. Validating with Silhouette Score
When the elbow curve is ambiguous, calculate the Silhouette Score (ranges from -1 to +1):
- Near +1: Clusters are dense and cleanly separated.
- Near 0: Clusters overlap significantly.
- Negative: Points are assigned to the wrong cluster.
4. Profiling Clusters for Business Strategy
After assigning cluster labels, profile each cluster by calculating unscaled feature means:
Multiple Choice Questions
init='k-means++' initialization algorithm over pure random initialization?RFM (Recency, Frequency, Monetary) Customer Segmentation
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.