AI Hints
Home›Data Science Tutorial›Case Studies: Menu and Customers
Data Science · Lesson 87 of 101

Case Study: Who to Keep

Where the money really is.

⏱ 2 min read▶ Video at 2:31:14🎓 Free
Watch this lesson in the Data Science courseWatch on YouTube ↗Full Data Science course

The marketing team has a budget of a hundred thousand dollars, to reduce customer churn. They plan to split it evenly, among all customers. Is that wise? Let's see where the value really sits.

Case Study: Who to Keep
From the video: Case Study: Who to Keep
  • A hundred thousand dollars
  • Split evenly among customers?
  • See where the value is

Step one: how concentrated is value?

We work out each customer's monthly value, sort them, and add up from the top. Run it. The top ten percent of customers bring in twenty nine percent of the value. The top fifth brings in forty six. And the bottom half brings in only twenty one percent. So an even split spends half of the money on people who bring in a fifth of the value.

case5_step1.pypython
import numpy as np
import pandas as pd

c = pd.read_csv("customers.csv").drop_duplicates().dropna(subset=["avg_spend", "visits_per_month"])
c["monthly"] = c["visits_per_month"] * c["avg_spend"]
c = c.sort_values("monthly", ascending=False)
share = c["monthly"].cumsum() / c["monthly"].sum()
print(f"Top 10% of customers: {share.iloc[len(c) // 10]:.0%} of value")
print(f"Top 20%: {share.iloc[len(c) // 5]:.0%}")
print(f"Bottom 50%: {1 - share.iloc[len(c) // 2]:.0%}")
Output
Top 10% of customers: 29% of value
Top 20%: 46%
Bottom 50%: 21%

Step two: value and risk together

Value is only half of the story. We also need to know who might leave. We group people by how often they visit. Run it. Look at the churn column. Those who visit once or twice a month leave at forty percent. Those who come more than ten times leave at just four percent. And look at the value. The heaviest group's worth twelve times as much as the lightest. So the top group is valuable, but it's already safe. The most interesting group is the middle one, of three to five visits. It's large, it's fairly valuable, and it's at real risk.

case5_step2.pypython
import pandas as pd

c = pd.read_csv("customers.csv").drop_duplicates().dropna(subset=["avg_spend", "visits_per_month"])
c["monthly"] = c["visits_per_month"] * c["avg_spend"]
c["visit_band"] = pd.cut(c["visits_per_month"], [0, 2, 5, 10, 100], labels=["1-2", "3-5", "6-10", "10+"])
print(c.groupby("visit_band", observed=True).agg(people=("monthly", "size"), monthly=("monthly", "mean"), churn=("churned", "mean")).round(2).to_string())
Output
            people  monthly  churn
visit_band
1-2           1319    13.28   0.40
3-5           2737    37.63   0.29
6-10          1649    80.57   0.17
10+            295   163.46   0.04

Step three: does location matter?

Should the money go to some cities? We check churn and card use by city. Run it. Churn runs from twenty six to twenty eight percent, and that's almost flat. So geography isn't the story. That's a useful negative result, as it saves a lot of wasted targeting. Not every slice reveals something. Report those too, as they rule things out.

case5_step3.pypython
import pandas as pd

c = pd.read_csv("customers.csv").drop_duplicates()
c["city"] = c["city"].str.strip().str.title()
t = c.groupby("city").agg(people=("churned", "size"), churn=("churned", "mean"), card=("loyalty", "mean"))
print(t.sort_values("churn").round(2).iloc[[0, 1, -2, -1]].to_string())
Output
       people  churn  card
city
Rome     1340   0.26  0.35
Cairo     712   0.27  0.33
Oslo     1328   0.28  0.35
Lagos    1283   0.28  0.37

What you recommend

Recommendation, don't split the money evenly. Focus it on people with three to five visits a month, as that's where churn and value overlap. Don't target by city. Keep the heaviest users happy with small gestures, as they're already loyal. And as you learned in the uplift lesson, run an experiment, to find who the offer really changes.

Target3-5 visits a month
Not by citychurn is flat
Top groupalready safe
Test upliftwho changes?

Summary

Combine value with risk, and report what didn't matter. Next, let's write the whole year's story.

Key takeaways
  • Value is concentrated
  • Combine value and risk
  • Report null results
Next up: Case Study: The Annual Review — one page for the whole year