Five kinds of shoppers walk into this mall.
. We scale each customer's age, annual income and spending score, then let K-Means find the groups, so every group can get an offer that suits it.
- Student
- Roll no.
- Subject
- College
Getting the data ready
Each dot is one customer.
Customers
Average age
Average annual income
Average spending score
What the customers look like
How the 3 clustering features are spread out, and the gender split.
Age
Annual income (₹ lakh)
Spending score
Gender
How it works
- 1
Scale the numbers
Income is in lakhs of rupees, age in years and the score runs 1 to 100. StandardScaler puts every column on the same scale (mean 0, spread 1), so no single column decides who is "close" to whom.
- 2
Pick K with the elbow method
We try K = 2 to 10 and plot WCSS, how spread out the groups are. Where the curve bends like an elbow, extra groups stop helping much. The silhouette score (higher is better) double-checks the choice.
- 3
Group with K-Means
K-Means drops K centre points, gives each customer to the nearest centre, moves each centre to the middle of its customers, and repeats until nothing changes. Each final group becomes a segment.
Try it on your own data
Upload a CSV with the columns CustomerID, Gender, Age, Annual Income (k$) and Spending Score (1-100), 30 to 5,000 rows. The whole app re-trains on it.
Loading…