Deployable Customer Churn Prediction with Explainable AI
📈 Turning the classic Kaggle Telco Customer Churn dataset into a modular, deployable ML platform with SHAP explainability and a Gradio front-end
Why Churn Prediction?
Customer churn directly impacts recurring revenue, retention spend, and overall business growth. While most churn projects stop at model accuracy in a notebook, I wanted to explore what it takes to design an end-to-end ML system that:
Supports multiple model types
Produces metrics and visualizations decision-makers can use
Explains why customers churn
Can be deployed for interactive use
Live Demo
👉 Try the Churn Prediction App
👉 View Code on GitHub
<div style="aspect-ratio:16/9; width:100%; max-width:1100px; margin:auto;"> <iframe src="https://ajaycyril-telcochurnzeroshot.hf.space?__theme=light" style="width:100%; height:100%; border:1px solid #e5e7eb; border-radius:10px;" allow="fullscreen; clipboard-read; clipboard-write"> </iframe> </div>
System Overview
The platform is structured into five layers:
Data ingestion & preprocessing
CSV upload or Kaggle dataset download
Handling missing values, categorical encoding, tenure bucketing
Model training
Logistic Regression, Random Forest, Gradient Boosting, XGBoost, CatBoost
Configurable CV folds and ensemble size
Automated best-model selection
Evaluation
Metrics: Accuracy, Precision, Recall, F1, ROC-AUC
Visuals: ROC curve and Confusion Matrix
Explainability
Global feature importance
Per-customer SHAP explanations (e.g., contract type, charges, tenure)
Waterfall plots for single-customer predictions
Deployment
Built with Gradio 4.x
Hosted on Hugging Face Spaces for instant access
Code Structure
telcochurnzeroshot/
├── data.py # data ingestion & preprocessing
├── train.py # model training & evaluation
├── explain.py # SHAP explainability
├── app_clean.py # Gradio UI orchestration
└── assets/ # ROC curves & confusion matrices
This modular approach makes it easy to extend the platform: add models, customize visualizations, or plug into enterprise data sources.
Key Insights from the Models
Across different algorithms, consistent signals emerged:
Contract type: month-to-month customers are the most likely to churn
Tenure: longer-tenure customers tend to stay
Monthly charges: higher fees correlate with higher churn
Tech support: availability reduces churn risk
These map directly to actionable business levers: loyalty programs, pricing strategies, and support services.
Lessons in System Design
Separation of concerns: data, training, explainability, UI
Reproducibility: deterministic build IDs for each deployment
Observability: logs across the pipeline for debugging & trust
Explainability-first: SHAP ensures the model isn’t a black box
Deployment-neutral: runs locally, on Hugging Face, or as a container
Roadmap
Future extensions could include:
Threshold tuning for precision vs recall tradeoffs
Cost-sensitive metrics tied to actual retention dollars
Batch/API scoring pipelines for production deployment
A policy engine mapping churn scores → recommended retention actions
Closing Thoughts
This project shows what it takes to transform a well-known dataset into a deployable, explainable ML platform. Instead of just optimizing accuracy, the focus is on trust, usability, and deployment — the things that matter when moving machine learning into production.
👉 Explore the Live Demo
👉 Check out the Code



