A end-to-end data science project that goes beyond "predict churn" and answers the question a business actually cares about: who should we spend retention budget on, and who's not worth it?
Built using the Telco Customer Churn dataset (Kaggle).
Most churn projects stop at a probability score. This one takes it further — combining customer segmentation, churn prediction, and estimated lifetime value into a single, actionable retention-priority framework.
- Data cleaning — handles missing/malformed values in
TotalCharges, encodes the churn label. - RFM-style feature engineering — adapts the classic Recency/Frequency/Monetary framework to a subscription business with no transaction log, using tenure, service count, and monthly spend as proxies.
- Customer segmentation (K-Means) — groups customers into behavioral segments based on the RFM features, after scaling and validating cluster count with the elbow method.
- Churn prediction (Random Forest) — predicts churn probability per customer, using tenure, spend, service engagement, segment, and one-hot encoded contract/payment/internet service type.
- Customer Lifetime Value (CLV) estimate — combines monthly spend with churn risk into a simplified expected-value calculation.
- Business interpretation layer — classifies every customer into one of four retention
priorities:
- 🔴 Urgent — high value, high churn risk → active retention offer
- 🟡 Monitor — high value, low risk → no action needed
- ⚪ Low priority — low value, high risk → not worth the spend
- 🟢 Stable — low value, low risk
| Metric | Score |
|---|---|
| Churn model ROC-AUC | ~0.85 |
| Customer segments identified | 4 |
(Update these numbers with your actual run output before publishing.)
Key insight: contract type (month-to-month vs. annual) was one of the strongest churn predictors in the dataset — customers without a contract commitment churn at a dramatically higher rate than those locked into 1- or 2-year plans.
├── customer_segmentation.py # full pipeline: clean → segment → predict → prioritize
├── telco_churn.csv # dataset (not included — download from Kaggle)
├── customer_segmentation_output.csv # generated output with all scores per customer
└── README.md
pip install pandas numpy scikit-learn
python customer_segmentation.pyThis prints churn model performance and a retention priority breakdown, and saves
customer_segmentation_output.csv with every customer's segment, churn probability,
estimated CLV, and recommended retention action.
- RFM's "recency" and "frequency" components are adapted proxies (tenure, service count) since this dataset has no transaction timestamps — a deliberate substitution, not literal RFM.
- CLV is a simplified estimate (
monthly spend × expected remaining months), not a finance-grade valuation — it's built for relative prioritization, not accounting. - Cluster count (k=4) was chosen using the elbow method on inertia across k=2–8.
- The churn model currently favors precision on "will stay" predictions over "will churn" predictions (an effect of class imbalance — ~27% of customers churned in this dataset) — worth tuning the decision threshold further in a production setting where missing a churner is costlier than a false alarm.
- Compare Random Forest against XGBoost / Logistic Regression for interpretability trade-offs
- Add SHAP values for per-customer churn explanations
- Build a small dashboard (Streamlit) to explore segments and retention priorities interactively
- Test alternate clustering methods (DBSCAN, hierarchical) for non-spherical customer groups
Telco Customer Churn — Kaggle (IBM sample dataset, ~7,000 customers)v