Jainam Gala

Machine learning case study · scikit-learn

Customer Churn Prediction

20.4% of 10,000 European bank customers left. Gradient boosting ranks who is likely to leave. Contacting the riskiest 20% reaches 63% of the people who churn.

← Back to Portfolio

How many customers leave

2,037 of 10,000 customers left, which is 20.4%. About 1 in 5. A model that predicts “everyone stays” would already be 79.6% accurate, so accuracy is not the headline metric.

20.4% churn
  • Left, 2,037 (20.4%)
  • Stayed, 7,963 (79.6%)
Copper is churn in every chart on this page. Grey is customers who stayed.

Segment rates below use all 10,000 customers. Model scores use the 2,000-customer test set, which contains 407 churners.

Who leaves

Age is the biggest driver, and churn peaks between 46 and 60

Churn climbs from age 35, peaks at 58.4% for ages 51–55, then falls. Customers over 65 churn at 13.3%, below the average. A single “50+” rate of 44.6% hides that drop.

0% 20% 40% 60% Average 20.4% 51–55: 58.4% 18–257.5% 26–307.5% 31–359.1% 36–4015.0% 41–4526.8% 46–5046.4% 51–5558.4% 56–6053.3% 61–6540.0% 65+13.3%
Churn rate by age band, all 10,000 customers. The dashed line is the 20.4% average. The y-axis runs from 0% to 70%.

Customers with 3–4 products almost all leave

Two products is the low point, at 7.6%. Customers with 3 or 4 products churn at 82.7% and 100%. That group is small: 326 customers, 3.3% of the book.

0% 50% 100% 27.7% 7.6% 82.7% 100% 1 productn = 5,084 2 productsn = 4,590 3 productsn = 266 4 productsn = 60
The blue dot is the lowest churn. The counts under the axis show that the 3- and 4-product rates come from small groups.

Germany and inactive members churn the most

German customers churn at 32.4%, about twice France (16.2%) and Spain (16.7%). Inactive members churn at 26.9%, against 14.3% for active members. Inactive customers in Germany are the highest cell, at 41.1%.

Active member Inactive member France Spain Germany 11.5% 21.1% 10.8% 23.4% 23.7% 41.1%
Each cell is the churn rate for that country and activity. Darker copper is a higher rate. Germany and inactive is the dark corner.

Gender gap

Women churn at 25.1% and men at 16.5%, a gap of 8.6 points. Women over 50 churn at 52.8% (604 customers).

Women 25.1% left Men 16.5%
Each bar is 100% of that group. Copper is the share who left. Grey is the share who stayed.

What does not matter

Tenure does not separate leavers from stayers. Churn stays between 17% and 23% at every tenure from 0 to 10 years. A credit card does not either: 20.8% without one, 20.2% with one.

Tenure doesn't predict churn 0% 25% 50% 17–23% at every year of tenure Dashed line: average 20.4% 0 years 10 years
The results report a range, not a rate for each year, so the chart is that band. The axis is fixed at 0–50% so a flat result still looks flat.

Model results

Gradient boosting was selected because it had the highest ROC-AUC. ROC-AUC measures how well the model ranks customers by risk. 0.5 is random guessing and 1.0 is perfect. It is not the share of churners the model catches.

Model Accuracy ROC-AUC Churners caught at 0.5 Precision at 0.5
Logistic regression82.7%0.79026.3%69.9%
Random forest86.2%0.85245.9%77.0%
Gradient boosting86.9%0.87048.6%78.9%
0 0.5 1 0 0.5 1 Random (0.5) True positive rate False positive rate
Gradient boosting, AUC 0.870, drawn from the approximate points in the results note. Random forest is 0.852 and logistic regression is 0.790. Their curves were not listed point by point, so they are not drawn here.

What the model uses

Age and number of products account for most of the ranking. Feature importance shows what the model relies on. It does not show what causes churn.

Age 36.5% Number of products 29.8% Active member 11.4% Balance 6.4% Germany 5.7% Balance-to-salary 2.3% Age group 41–50 2.2% Credit score 1.7%
Share of gradient boosting importance. Age and product count dominate the ranking.

Choosing the cutoff

At the default 0.5 cutoff the model catches 48.6% of churners. A lower cutoff catches more of them and flags more people who would have stayed. At 0.3, recall and precision are both about 64%.

Cutoff Customers flagged Churners caught Flagged who leave
0.11,06790.7%34.6%
0.261176.9%51.2%
0.341764.6%63.1%
0.431254.5%71.2%
0.525148.6%78.9%
0.618539.8%87.6%
0.714031.4%91.4%
Chosen cutoff 0.3 100% 50% 0% 0.1 0.2 0.3 0.4 0.5 0.6 0.7
Copper is churners caught (recall). Navy is flagged customers who actually leave (precision). The lines meet at the 0.3 cutoff. The table has no rows past 0.7, so the axis stops there.

Confusion matrix at the 0.3 cutoff

Predicted stay Predicted leave Actually stayed Actually left 1,439 Correct stay 154 False alarm 144 Missed churner 263 Caught churner
Test set of 2,000 customers. At 0.3 the model flags 417 people, and 263 of the 407 churners are in that list.

How well the ranking concentrates churners

Contacting the riskiest 20% of customers reaches 63.1% of all churners, 3.2 times a random list. In the top 10%, 84.5% of the customers contacted actually leave.

Riskiest customers contactedShare of all churners reached
Top 10%41.5%
Top 20%63.1%
Top 30%76.7%
Top 40%83.3%
Top 50%89.7%
Top 20% → 63% of churners Random targeting 0% 50% 100% 0% 50% contacted 100% Customers contacted, riskiest first
The shaded line is the model. The dashed diagonal is a random list. Points past 50% are 60% → 93.1%, 70% → 96.3%, 80% → 97.8%, 90% → 99.0%, 100% → 100%.

Recommendations

  1. Score every customer monthly and contact the riskiest 20% first. That list reaches 63% of the customers who are about to leave.
  2. Use a 0.3 probability cutoff for the “at risk” flag, not 0.5. It catches 64.6% of churners instead of 48.6%, and about 6 in 10 flagged customers actually leave.
  3. Focus retention on customers aged 46–60. Their churn rate is 46–58%, more than double the average. Customers over 65 churn at only 13.3%.
  4. Win back inactive German customers. They churn at 41.1%. Usage rewards and check-in calls fit here, because inactivity is something the bank can influence.
  5. Investigate customers with 3–4 products. 83–100% of them leave, in a small group of 326 people. Moving 1-product customers to 2 products is the safer offer, at 7.6% churn.
  6. Look into the gender gap. Women churn at 25.1% against 16.5% for men, and at 52.8% over age 50.
  7. Retrain the model each quarter and check that recall at the 0.3 cutoff stays around 65% on new data.

Limits

Project resources

View the notebook View the repository
← Back to Portfolio