A production-ready Final Year CSE project combining Traditional ML, Deep Learning (Bidirectional LSTM), and Hybrid models for customer churn prediction β with SHAP explainability, K-Means segmentation, and an interactive Streamlit dashboard.
- 6 Models trained and compared β Logistic Regression, Random Forest, XGBoost, Bi-LSTM, Hybrid Weighted, Hybrid Stacking
- Best ROC-AUC: 0.8416 (Logistic Regression) on Telco Customer Churn dataset
- SHAP Explainability β identifies top features driving churn per customer
- K-Means Customer Segmentation β clusters customers into behavioral groups with targeted retention strategies
- ROC Curves + Confusion Matrices + Precision-Recall Curves for all 6 models
- Rule-based Retention Engine β personalized recommendations per customer
- Interactive Streamlit Dashboard β 6 fully functional tabs
| Model | Accuracy | ROC-AUC | Precision | Recall | F1-Score |
|---|---|---|---|---|---|
| Logistic Regression | 0.8070 | 0.8416 | 0.6584 | 0.5668 | 0.6092 |
| Random Forest | 0.7871 | 0.8169 | 0.6203 | 0.5241 | 0.5681 |
| XGBoost | 0.7736 | 0.8217 | 0.5868 | 0.4973 | 0.5384 |
| Bidirectional LSTM | 0.7878 | 0.8381 | 0.6364 | 0.4679 | 0.5393 |
| Hybrid Weighted | 0.7970 | 0.8399 | 0.6538 | 0.5000 | 0.5667 |
| Hybrid Stacking | 0.7828 | 0.8105 | 0.6090 | 0.5080 | 0.5539 |
Dataset: Telco Customer Churn β 7,043 customers, 26.54% churn rate
Project overview, system architecture table, and model readiness status.
- Upload any Telco-format CSV
- Runs all 6 models instantly
- KPI cards: Total / High / Medium / Low risk counts
- Churn probability distribution histogram
- Risk level pie chart
- Expandable retention recommendations per high-risk customer
- Download predictions as CSV
- Manual input form (demographics, services, billing)
- Prediction from all 6 models shown as metrics
- Interactive churn gauge chart (Hybrid Stacking)
- Personalized retention recommendations
- Full metrics table with green highlights for best scores
- Grouped bar chart (Accuracy, ROC-AUC, F1-Score)
- ROC Curves β all 6 models overlaid on one chart with AUC scores
- Confusion Matrices β all 6 models in a 3-column grid
- Precision-Recall Curves β better for imbalanced churn data
- SHAP Summary Dot Plot β feature impact direction per customer
- SHAP Bar Chart β average feature importance ranking
- Top 10 features table with churn impact direction
- Interactive Plotly bar chart colored by churn direction
Top Churn Drivers found by SHAP:
Contract_Month-to-month(0.8402) β strongest churn signaltenure(0.7148) β lower tenure = higher riskMonthlyCharges(0.4244)TotalCharges(0.4041)InternetService_Fiber optic(0.3264)
- Elbow Method chart to find optimal K
- PCA 2D Scatter β customers plotted as colored segments
- Cluster Profile Table β avg tenure, charges, churn risk per segment
- Churn Risk Bar Chart per segment
- Radar Chart β normalized feature comparison across segments
- Retention Strategy β specific action plan per segment (High/Medium/Low)
- Download segmented customer list as CSV
churn_project/
βββ data/
β βββ WA_Fn-UseC_-Telco-Customer-Churn.csv β Download from Kaggle
βββ models/ β Auto-created after training
β βββ logistic_regression.pkl
β βββ random_forest.pkl
β βββ xgboost.pkl
β βββ lstm_model.h5
β βββ meta_model.pkl
β βββ scaler.pkl
β βββ feature_names.pkl
β βββ shap_summary.png
β βββ shap_bar.png
βββ scripts/
β βββ preprocess.py β Data cleaning & feature engineering
β βββ train_ml.py β Logistic Regression, Random Forest, XGBoost
β βββ train_lstm.py β Bidirectional LSTM (TensorFlow/Keras)
β βββ hybrid_model.py β Weighted Average + Stacking hybrid
β βββ explainability.py β SHAP TreeExplainer analysis & plots
β βββ recommendation.py β Rule-based retention engine
βββ app.py β Streamlit dashboard (6 tabs)
βββ train_all.py β Master script β trains all models in order
βββ requirements.txt
βββ README.md
git clone https://github.com/nithinrbharadwaj/Hybrid-Churn-Prediction-System.git
cd Hybrid-Churn-Prediction-Systempy -3.12 -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linuxpip install -r requirements.txt- Go to: https://www.kaggle.com/datasets/blastchar/telco-customer-churn
- Download
WA_Fn-UseC_-Telco-Customer-Churn.csv - Place it inside the
data/folder
python train_all.pyTraining phases:
- β Phase 1: ML Models (Logistic Regression, Random Forest, XGBoost)
- β Phase 2: Bidirectional LSTM Deep Learning model
- β Phase 3: Hybrid models (Weighted Average + Meta-Learner Stacking)
- β Phase 4: SHAP explainability plots
streamlit run app.pyOpen: http://localhost:8501
| Category | Libraries |
|---|---|
| Data Processing | Python 3.12, Pandas, NumPy |
| Machine Learning | Scikit-learn, XGBoost |
| Deep Learning | TensorFlow 2.17, Keras (Bidirectional LSTM) |
| Explainability | SHAP (TreeExplainer) |
| Clustering | Scikit-learn KMeans, PCA |
| Dashboard | Streamlit, Plotly |
| Visualization | Matplotlib, Seaborn, Plotly |
Raw CSV Data
β
βΌ
Preprocessing (Label Encoding, One-Hot, StandardScaler)
β
ββββΊ Traditional ML βββΊ LR / RF / XGBoost
β
ββββΊ Deep Learning βββΊ Bidirectional LSTM
β
ββββΊ Hybrid βββΊ Weighted Avg / Stacking
β
ββββΊ Explainability βββΊ SHAP TreeExplainer
β
ββββΊ Segmentation βββΊ K-Means + PCA
β
ββββΊ Dashboard βββΊ Streamlit (6 tabs)
- All trained models are saved to
models/automatically - The
data/folder must contain the Kaggle CSV before runningtrain_all.py - SHAP PNG plots are saved to
models/and displayed in the Explainability tab - The retention engine is rule-based β no extra training needed
- For segmentation, upload the same CSV in the Segmentation tab
- SMOTE for class imbalance handling
- Hyperparameter tuning with Optuna
- FastAPI real-time prediction endpoint
- What-If simulator (change features, see new risk score)
- PDF report generator
- Docker containerization
- Streamlit Cloud deployment
- Survival Analysis (predict when customer will churn)
Nithin R Bharadwaj Final Year CSE β Hybrid Churn Prediction System



