Skip to content

mahdidadgar-data/customer-churn-prediction-retention-strategy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Customer Churn Prediction and Retention Strategy

Project Overview

Customer churn is a major challenge for subscription-based businesses because losing customers directly reduces recurring revenue. This project uses machine learning to predict customer churn for a telecom subscription business and support retention campaign prioritization.

The goal is not only to classify customers as churn or non-churn, but also to support business decision-making by identifying high-risk customers, tuning the classification threshold, estimating retention value, and recommending targeted retention actions.

Business Problem

The central business question is:

Which customers are most likely to churn, and how can the company prioritize retention actions to reduce revenue loss?

In this project, churn prediction is treated as a business decision-support problem. False negatives are especially important because missing a truly high-risk customer can lead to lost revenue. False positives also matter because unnecessary retention offers create campaign costs.

Dataset

This project uses the Telco Customer Churn dataset from Kaggle.

Dataset source:

https://www.kaggle.com/datasets/blastchar/telco-customer-churn

The dataset contains customer-level information for a telecom subscription business, including customer demographics, subscribed services, contract type, payment method, monthly charges, total charges, and churn status.

The raw dataset is not included in this repository. See data/README.md for details.

Project Structure

customer-churn-prediction-retention-strategy
├── README.md
├── data
│   └── README.md
├── docs
│   └── project_summary.md
├── images
│   ├── churn_by_contract_type.png
│   ├── churn_by_tenure_group.png
│   ├── final_confusion_matrix.png
│   ├── model_comparison.png
│   └── README.md
├── notebooks
│   └── customer_churn_prediction_retention_strategy.ipynb
├── reports
│   └── customer_churn_project_overview.pdf
└── src

Project Visuals

Churn Rate by Contract Type

Month-to-month customers showed a much higher churn rate than customers with one-year or two-year contracts.

Churn Rate by Contract Type

Churn Rate by Tenure Group

Customers in the earliest tenure groups showed the highest churn risk, indicating an important early-retention opportunity.

Churn Rate by Tenure Group

Model Comparison

Multiple models were compared using classification and ranking metrics, including recall, F1-score, ROC-AUC, and PR-AUC.

Model Comparison

Final Confusion Matrix

The final model was evaluated at the selected business-aware threshold of 0.40.

Final Confusion Matrix

Tools and Technologies

  • Python
  • Pandas
  • NumPy
  • Matplotlib
  • Seaborn
  • Scikit-learn
  • Jupyter Notebook / Google Colab
  • Kaggle dataset access

Machine Learning Workflow

The project follows a structured machine learning workflow:

  1. Business problem definition
  2. Dataset loading and inspection
  3. Data quality checks
  4. Data cleaning and target encoding
  5. Exploratory data analysis
  6. Feature engineering
  7. Preprocessing pipeline
  8. Baseline model development
  9. Logistic Regression modeling
  10. Class-weighted Logistic Regression
  11. Random Forest modeling
  12. Model comparison
  13. Business-aware threshold tuning
  14. Profit-based retention simulation
  15. Model interpretation
  16. Business recommendations

Exploratory Data Analysis Highlights

The EDA focused on churn rates rather than only raw customer counts. Key churn patterns included:

Customer Segment Churn Rate
Month-to-month contract customers 42.71%
One-year contract customers 11.27%
Two-year contract customers 2.83%
Customers with 0–6 months tenure 52.94%
Electronic check users 45.29%
Fiber optic customers 41.89%
Customers without OnlineSecurity 41.77%
Customers without TechSupport 41.64%

These insights showed that high-risk churn segments include new customers, month-to-month customers, electronic check users, fiber optic customers, customers with higher monthly charges, and customers without key support services.

Model Results

Several models were compared:

Model Accuracy Precision Recall F1-score ROC-AUC PR-AUC
Dummy Classifier 0.7346 0.0000 0.0000 0.0000 0.5000 0.2654
Logistic Regression 0.7984 0.6502 0.5160 0.5761 0.8451 0.6545
Class-Weighted Logistic Regression 0.7488 0.5175 0.7888 0.6250 0.8447 0.6544
Random Forest 0.7722 0.5540 0.7273 0.6289 0.8418 0.6495

The Class-Weighted Logistic Regression model was selected as the main model because it achieved high recall, strong ROC-AUC and PR-AUC, and better interpretability than the Random Forest model.

Threshold Tuning and Business Simulation

The default classification threshold of 0.50 was not automatically accepted. Multiple thresholds were tested to evaluate the trade-off between precision, recall, false positives, false negatives, and campaign size.

A profit-based retention simulation was performed using the following assumptions:

Business Assumption Value
Retention offer cost per targeted customer 50
Retention success rate 30%
Revenue horizon 12 months

The best threshold based on estimated net business value was 0.40.

At threshold 0.40:

Metric Value
Targeted Customers 692
True Churners Targeted 326
Estimated Saved Customers 97.8
Campaign Cost 34,600
Potential Retained Revenue 86,821.02
Net Estimated Value 52,221.02

Final Model Performance

At the selected threshold of 0.40, the final model achieved:

Metric Value
Accuracy 70.62%
Precision 47.11%
Recall 87.17%
F1-score 61.16%
ROC-AUC 84.47%
PR-AUC 65.44%

Final confusion matrix:

Predicted No Churn Predicted Churn
Actual No Churn 669 366
Actual Churn 48 326

The final model correctly identified 326 out of 374 churned customers in the test set.

Business Recommendations

The model should be used as a decision-support tool for retention planning.

Recommended high-risk customer groups:

  • New customers
  • Month-to-month contract customers
  • Electronic check users
  • Fiber optic customers
  • Customers with high monthly charges
  • Customers without key support services

Recommended retention actions:

Customer Segment Recommended Action
New month-to-month customers Onboarding support and contract upgrade incentive
Electronic check users Automatic payment incentive
Customers without support services Support-service bundle
High-charge or fiber optic customers Price-value review or loyalty offer
Other high-risk customers General retention follow-up

Key Business Value

This project demonstrates how machine learning can support customer retention strategy by:

  • identifying customers with high churn risk
  • reducing missed churners through recall-focused modeling
  • selecting a business-aware classification threshold
  • estimating the financial impact of retention campaigns
  • translating model results into practical business actions

Limitations and Future Improvements

This project has several limitations:

  • Business simulation values are assumptions and should be validated with stakeholders.
  • The model was evaluated using a train-test split from the same dataset.
  • Some engineered features overlap with original variables.
  • Logistic Regression coefficients should be interpreted carefully.
  • The model identifies associations, not causal relationships.
  • Real-world deployment would require monitoring, retraining, fairness checks, and business validation.

Possible future improvements:

  • Validate retention cost and success-rate assumptions with real business data
  • Add cross-validation for more robust model evaluation
  • Test additional models such as Gradient Boosting, XGBoost, or LightGBM
  • Add SHAP-based model interpretation
  • Build a customer risk scoring dashboard
  • Monitor model performance over time after deployment

Repository Files

Author

Mahdi Dadgar
PhD background in Animal Science and Animal Nutrition
Career transition into Data Analytics, Business Intelligence, Data Science, and AI

About

Machine learning project to predict customer churn and support retention strategy using threshold tuning, profit simulation, and model interpretation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors