Customer Segments
Who to look after.
Marketing wants to send the same coupon to all six thousand customers. You know that's wasteful. Some would have bought anyway, and some aren't worth it. Before you reach for a clustering algorithm, try a simple table. It's the method that most retail companies really use.

- One coupon for everyone?
- That's wasteful
- Start with a simple table
Three by three
We clean the customers, and we calculate monthly spend, which is visits times average spend. Then Q cut splits each measure into three equal groups, low, middle, and high. One column for how often people visit, and one for how much they spend per visit. Finally, a group by gives each of the nine cells its size, its monthly spend, and its churn rate. Run it. The best cell has over eight hundred people, who spend about a hundred and twenty three dollars each month. The worst spends about twelve, which is ten times less. Now look at churn. Read down it, and you'll see something important. Churn hardly changes with spend. It changes with visits. From about thirty seven percent at low visits, down to about fifteen at high visits.
import pandas as pd
c = pd.read_csv("customers.csv").drop_duplicates("customer_id")
c = c.dropna(subset=["visits_per_month", "avg_spend"])
c["monthly"] = c["visits_per_month"] * c["avg_spend"]
c["freq"] = pd.qcut(c["visits_per_month"], 3, labels=["low", "mid", "high"])
c["value"] = pd.qcut(c["avg_spend"], 3, labels=["low", "mid", "high"])
table = c.groupby(["freq", "value"], observed=True).agg(
people=("monthly", "size"), monthly=("monthly", "mean"), churn=("churned", "mean"))
print(table.round(2).to_string()) people monthly churn
freq value
low low 898 12.52 0.37
mid 604 17.66 0.39
high 544 25.40 0.39
mid low 685 29.58 0.27
mid 642 39.33 0.28
high 627 57.67 0.27
high low 427 55.35 0.17
mid 745 78.62 0.16
high 828 123.17 0.14From a table to actions
A good segment comes with a plan. Frequent, big spenders are your treasure, so protect them with service rather than discounts. Frequent, small spenders might buy a pastry, so try suggesting one. People with few visits and big orders might respond to a reminder. And rare, small buyers shouldn't get costly offers. Notice that the coupon could be wasted on your best customers.
A table or clustering?
Clustering might find a more detailed pattern. But a manager can't easily remember cluster four. A table has clear rules, it's stable from month to month, and everyone can repeat it. Start with the table. Move to clustering only if it leads to better decisions, which you can show with an experiment.
Simple table
- Rules anyone can repeat
- Stable month to month
- Easy to act on
Clustering
- May find finer patterns
- Labels can shift
- Hard to explain
Beware of moving people
Here's a subtle trap. Suppose that you pick your lowest spending customers, and send them a coupon. Next month, they spend more. Did the coupon work? Perhaps not. People who had an unusually bad month tend to drift back to normal anyway. That's regression to the mean. So hold back a random part of each segment, with no offer. Only then will you know what the coupon really did.
Summary
Segments are only useful if each one has a plan. And churn followed visits, rather than spend. Next, is the famous eighty twenty rule really true?
Key takeaways- Use a simple table first
- Churn followed visits
- Each segment needs a plan