K-Means Clustering & the Elbow Method
Deep Theory + Interactive Understanding
Clustering is an unsupervised learning problem — meaning we do not know the correct answers in advance. Unlike classification, there are no labels.
K-Means clustering forces structure onto data by grouping similar points together. But before clustering, we must answer a deceptively hard question:
๐ How many clusters should exist?
What K-Means Is Really Doing (Theory)
K-Means assumes that data can be partitioned into K spherical groups, each represented by a centroid (mean).
Minimize:
ฮฃ (distance between each point and its assigned cluster centroid)²
This objective function explains everything:
- Why distance matters
- Why clusters tend to be round
- Why outliers distort results
Why WCSS Always Decreases as K Increases
WCSS (Within-Cluster Sum of Squares) measures how compact clusters are.
- Points have more centroids to choose from
- Distances to centroids become smaller
- Worst case: a cluster contains one point → distance = 0
This is why:
- K = number of data points → WCSS = 0
- But this solution is meaningless
Bias–Variance Tradeoff (Applied to Clustering)
High bias → oversimplified view of data (underfitting)
High variance → noisy, unstable clusters (overfitting)
The Elbow Method is trying to find the balance point between bias and variance.
๐ Interactive Elbow Method Visualization
Move the slider to change the number of clusters (K) and observe diminishing returns.
Why the Elbow Is Subjective
In real datasets:
- The curve may be smooth with no clear bend
- Multiple elbows may appear
- Different stakeholders may prefer different K values
This is why clustering is a decision-making process, not just a computation.
When the Elbow Method Fails
- Clusters have different sizes or densities
- Data is non-spherical
- High-dimensional feature spaces
- Strong noise or outliers
๐ก Key Takeaways
- K-Means minimizes squared distance to centroids
- WCSS always decreases — improvement is the key signal
- The elbow represents diminishing returns, not perfection
- Choosing K is a trade-off between simplicity and detail
- Clustering combines math, visualization, and judgment
No comments:
Post a Comment