End-to-End Machine Learning System for Customer Retention with Business Cost Optimization
Customer churn is one of the most critical challenges for subscription-based businesses. Instead of focusing solely on prediction accuracy, this project applies cost-sensitive machine learning to optimize business outcomes.
The system identifies customers who are likely to churn, evaluates the financial impact of prediction errors, tunes the classification threshold based on business cost, and provides an interactive dashboard for retention decision-making.
- π Exploratory Data Analysis (EDA)
- π§Ή Data Cleaning & Preprocessing
- βοΈ Feature Engineering
- βοΈ Class Imbalance Handling
- π€ Multiple Machine Learning Models
- π― Threshold Optimization
- π° Business Cost Function
- π ROI & Revenue Loss Analysis
- π Confusion Matrix Analysis
- π Interactive Streamlit Dashboard
- π€ Individual Customer Scoring
- π Batch Customer Prediction
- π Data Quality Dashboard
Experience the interactive Streamlit dashboard designed to transform churn predictions into actionable business insights.
Monitor customer churn rate, risk distribution, flagged customers, and total CLTV exposure through an executive-friendly dashboard.
Filter customers by risk level, contract type, and churn probability to generate targeted retention action lists.
Compare intervention strategies, estimate financial exposure, optimize retention costs, and evaluate projected savings.
Score individual models, predict churn probability, assign risk segments, and support retention decisions.
Optimizes a ML classification threshold to balance missed churners against false alarms, minimizing total financial costs for the business.
outlines the data preparation, modeling, and cost-focused evaluation strategy used to build and select the optimal churn prediction system.
The solution follows an end-to-end machine learning workflowβfrom raw customer data ingestion to business-driven retention recommendations delivered through an interactive Streamlit dashboard.
Raw Customer Data
β
βΌ
Data Cleaning
β
βΌ
Feature Engineering
β
βΌ
Encoding & Scaling
β
βΌ
Class Imbalance Handling
β
βΌ
Train Multiple Models
β
βΌ
Model Evaluation
β
βΌ
Threshold Optimization
β
βΌ
Business Cost Analysis
β
βΌ
Model Deployment (Streamlit)
- Logistic Regression
- Random Forest
- XGBoost
- LightGBM
The best-performing model is selected based on predictive performance and business impact rather than accuracy alone.
Unlike traditional churn prediction projects, this solution evaluates the financial impact of model decisions.
The optimization considers:
- False Positive Cost
- False Negative Cost
- Customer Lifetime Value (CLTV)
- Decision Threshold Optimization
- Revenue Loss Estimation
- Retention ROI
This enables data-driven retention strategies instead of relying on a default 0.5 classification threshold.
The Streamlit application includes:
- Customer churn rate
- Customers flagged for retention
- CLTV exposure
- Risk distribution
- Filter customers by risk level
- Contract type analysis
- Probability threshold filtering
- Export retention action lists
- Predict churn probability for a single customer
- Risk categorization
- Retention recommendation
- Compare intervention strategies
- Revenue exposure
- Estimated savings
- Offer investment analysis
- Missing values
- Dataset statistics
- Column summaries
- Data profiling
Cost-Sensitive-Churn-Prediction/
β
βββ artifacts/
β βββ churnmodel.pkl
β βββ modelcolumns.pkl
β βββ bestthreshold.pkl
β βββ labelencoders.pkl
β
βββ assets/
β βββ overview.png
β βββ risk-explorer.png
β βββ customer-scoring.png
β βββ business-impact.png
β βββ data-quality.png
β βββ model-pipeline.png
β βββ demo.gif
β
βββ data/
β βββ raw/
β βββ processed/
β
βββ notebooks/
β βββ churn_prediction.ipynb
β
βββ app.py
βββ requirements.txt
βββ README.md
βββ LICENSE
βββ .gitignore
Clone the repository
git clone https://github.com/yourusername/Cost-Sensitive-Churn-Prediction.gitMove into the project
cd Cost-Sensitive-Churn-PredictionInstall dependencies
pip install -r requirements.txtstreamlit run app.pyThis project uses the Telco Customer Churn Dataset, which contains customer demographics, subscription information, service usage, billing details, and churn labels.
Key attributes include:
- Customer Demographics
- Contract Information
- Internet Services
- Payment Methods
- Monthly Charges
- Total Charges
- Customer Lifetime Value (CLTV)
- Churn Status
- Machine Learning
- Classification
- Cost-Sensitive Learning
- Business Analytics
- Feature Engineering
- Threshold Optimization
- Model Evaluation
- Hyperparameter Tuning
- Streamlit
- Data Visualization
- Business Intelligence
- SHAP Explainability
- Customer Segmentation
- AutoML Integration
- MLflow Experiment Tracking
- Docker Deployment
- Cloud Deployment (AWS/Azure)
- Real-Time Prediction API
- Drift Monitoring
- Customer Recommendation Engine
If you found this project helpful, consider giving it a Star β.
Feedback, suggestions, and contributions are always welcome.








