Why scaling matters for K-Means and how StandardScaler works.
K-Means clustering uses Euclidean distance to measure similarity between customers. If features are on different scales, the algorithm will be biased towards the feature with the largest range.
After scaling: mean becomes 0 and standard deviation becomes 1 for each feature. Values are unitless and directly comparable.
Annual income in thousands of dollars. Range: 15k–137k. Strong economic indicator.
Mall-assigned spending behaviour score (1=low, 100=high). Captures buying habits.
| # | Annual Income | Spending Score |
|---|---|---|
| 1 | 15 | 39 |
| 2 | 15 | 81 |
| 3 | 16 | 6 |
| 4 | 16 | 77 |
| 5 | 17 | 40 |
| 6 | 17 | 76 |
| 7 | 18 | 6 |
| 8 | 18 | 94 |
| # | Annual Income (z) | Spending Score (z) |
|---|---|---|
| 1 | -1.739 | -0.4348 |
| 2 | -1.739 | 1.1957 |
| 3 | -1.7008 | -1.7159 |
| 4 | -1.7008 | 1.0404 |
| 5 | -1.6627 | -0.396 |
| 6 | -1.6627 | 1.0016 |
| 7 | -1.6245 | -1.7159 |
| 8 | -1.6245 | 1.7004 |