Splitting 200 mall customers into actionable groups by age, annual income and spending score, so marketing spend can be aimed at segments instead of spread evenly across everyone.
Six segments, with k chosen by silhouette score. Ranked by mean spending score they fall
into three clear tiers:
| Tier | Clusters | Customers | Mean spending score |
|---|---|---|---|
| High spenders | 3, 2 | 63 (32%) | 82.1 and 76.9 |
| Mid spenders | 1, 4 | 83 (42%) | 49.1 and 47.8 |
| Low spenders | 5, 0 | 54 (27%) | 19.4 and 17.0 |
The gaps between tiers are large — 82 against 49 against 17 — so these are distinct groups rather than an arbitrary slicing of a continuum.
- High spenders (32% of the base) — retention and loyalty spend belongs here. This is the group whose loss costs the most per customer.
- Mid spenders (42%) — the largest tier, and where upsell has room to move. A customer at 49 has more headroom than one already at 82.
- Low spenders (27%) — worth understanding before spending on. Low income and low engagement need different responses, and the income axis separates the two.
Scaling before clustering. K-Means uses Euclidean distance, and annual income runs to 137
while spending score caps at 99. Without StandardScaler, income would dominate the distance
calculation purely because of its units.
Choosing k with two methods. The elbow method on inertia is a judgement call; silhouette score gives a number to compare. Both were run, and k = 6 has the highest silhouette score.
Dropping gender. Encoded and correlated against spending score first — it carries almost no relationship, while age does. The clustering runs on the three variables a marketing team can act on.
Honest limitation. K-Means assumes spherical, similarly-sized clusters and will always
return exactly k groups whether or not the data contains them. The silhouette score supports
k = 6, but these segments are a decision-making tool rather than a discovered truth —
validating them against real campaign response is the next step.
├── notebooks/customer_segmentation.ipynb # full analysis, outputs included
├── data/ # dataset goes here (see below)
└── requirements.txt
git clone https://github.com/mpozz98/customer-segmentation.git
cd customer-segmentation
pip install -r requirements.txt
# place mall_customers.csv in ./data
jupyter notebook notebooks/customer_segmentation.ipynbpandas · scikit-learn · matplotlib · seaborn
Part of a data-analytics portfolio built during an AI/Data Science bootcamp.