Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Customer Segmentation & Retention Analysis

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).

What this project does

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.

  1. Data cleaning — handles missing/malformed values in TotalCharges, encodes the churn label.
  2. 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.
  3. Customer segmentation (K-Means) — groups customers into behavioral segments based on the RFM features, after scaling and validating cluster count with the elbow method.
  4. Churn prediction (Random Forest) — predicts churn probability per customer, using tenure, spend, service engagement, segment, and one-hot encoded contract/payment/internet service type.
  5. Customer Lifetime Value (CLV) estimate — combines monthly spend with churn risk into a simplified expected-value calculation.
  6. 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

Results

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.

Project structure

├── 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

How to run

pip install pandas numpy scikit-learn
python customer_segmentation.py

This 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.

Methodology notes & honest limitations

  • 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.

Possible extensions

  • 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

Dataset

Telco Customer Churn — Kaggle (IBM sample dataset, ~7,000 customers)v

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages