Customer Churn Prediction¶
Every subscription business lives or dies by churn. When a customer cancels, you lose not just one month's revenue — you lose the entire expected lifetime value of that relationship. This project builds a binary classifier that predicts which customers will cancel their subscription in the next 30 days, so the retention team can intervene before it's too late.
Why Churn Prediction Matters¶
Acquiring a new customer costs 5–7x more than retaining an existing one. Even a 5% reduction in churn can increase profitability by 25–95% (Bain & Company). The model's output is not an academic exercise — it is a ranked list of at-risk customers handed to a retention team who will make real calls to real people.
That business framing changes how you build and evaluate the model. Accuracy is the wrong metric. Recall is what keeps customers.
Info
This project mirrors real-world churn prediction work at SaaS companies, telecom providers, and subscription e-commerce. The patterns you learn here apply directly to problems like Netflix subscriber retention, Spotify premium conversion, and B2B SaaS contract renewal.
Learning Objectives¶
By completing this project you will be able to:
- Frame a business problem as a binary classification task with appropriate success metrics
- Perform EDA on a realistic business dataset and identify the dominant churn signals
- Engineer features that capture customer behavior patterns not present in raw columns
- Build and compare multiple classifiers with proper handling of class imbalance
- Tune the decision threshold to match the business constraint (recall vs. precision tradeoff)
- Communicate model results to a non-technical stakeholder using confusion matrix business translation and lift curves
Skills You Will Practice¶
| Skill | Where |
|---|---|
| EDA on business data | eda |
| Feature engineering | feature-engineering |
| Binary classification | model-building |
| Class imbalance handling | model-building |
| Threshold tuning | model-building, evaluation |
| ROC / PR curves | evaluation |
| Cohort analysis | eda, evaluation |
| Business metric translation | evaluation |
Prerequisites¶
You should be comfortable with the following before starting:
- Week-02 Day-02 Part-1: Classification Algorithms — logistic regression, trees, random forests, gradient boosting
- Week-01 Day-04 Part-1: Matplotlib and Seaborn for visualization
- Week-01 Day-03: Pandas for data manipulation
- Week-02 Day-02 Part-2 (Clustering) is not required for this project
Project Structure¶
| File | Purpose |
|---|---|
README.md |
Project overview, objectives, business context (this file) |
dataset-guide.md |
Dataset generation, column reference, churn probability design |
eda.md |
Exploratory data analysis — distributions, correlations, churn drivers |
feature-engineering.md |
Imputation, engineered features, encoding, scaling, sklearn Pipeline |
model-building.md |
Baseline, three classifiers, threshold tuning, model comparison |
evaluation.md |
Confusion matrix, ROC/PR curves, feature importance, business ROI |
interview-questions.md |
8 interview questions with model answers |
The Dataset¶
No download required. Generate the dataset in code — a synthetic but realistic 1,000-customer subscription dataset.
import pandas as pd
import numpy as np
rng = np.random.default_rng(42)
n = 1000
tenure = rng.integers(1, 72, n)
segment = rng.choice(["Basic", "Premium", "Enterprise"], n, p=[0.55, 0.35, 0.10])
support_calls = rng.integers(0, 15, n).astype(float)
churn_prob = (
0.55 - tenure * 0.008 + support_calls * 0.04
- (segment == "Premium") * 0.12
- (segment == "Enterprise") * 0.20
+ np.random.normal(0, 0.05, n)
)
The full generation code — including all 10 columns and realistic missingness — is in dataset-guide.
Business Framing¶
The model's job is to produce a ranked list of customers most at risk of churning in the next 30 days. The retention team uses this list to prioritise outreach calls.
Key constraints the model must respect:
- The retention team can handle roughly 150 calls per week
- A missed churner costs the business the full remaining lifetime value of that customer
- A false positive costs one unnecessary retention call (~15 minutes of agent time)
This asymmetry means the model should optimise for recall, not accuracy. You will explore exactly how to make that tradeoff explicit in model-building and evaluation.
Tip
Before you write a single line of model code, write down the business success criteria: "We want to capture at least 70% of churners while keeping the false positive rate low enough that the retention team is not overwhelmed." That sentence guides every modelling decision you make.
Next: dataset-guide