An end-to-end machine learning and MLOps platform designed to predict customer churn, segment customers, quantify financial risk, explain model decisions, and prioritize retention actions.
This project evolved from a traditional customer churn prediction model into an end-to-end customer intelligence platform for banking. The solution combines supervised machine learning, customer segmentation, quantitative risk scoring, explainable AI, model calibration, monitoring, REST APIs, cloud data storage, experiment tracking, and automated CI/CD.
Five classification models were evaluated using multiple performance metrics. Gradient Boosting is currently used within the risk-scoring and monitoring workflow, while Logistic Regression is retained for interpretable quantitative analysis. The platform also uses K-Means clustering to identify customer segments and combines churn probability with customer value to support retention prioritization.
Customer attrition can significantly affect revenue and long-term customer value in the banking sector. A useful churn system therefore needs to do more than simply predict whether a customer will leave.
The objective of this project is to identify customers with elevated churn probability, understand the factors associated with that risk, estimate potential financial exposure, and provide a framework for prioritizing retention activity.
The project uses a European bank customer churn dataset containing 10,000 customer records with demographic, financial, product, engagement, and churn information.
Customer Records
Original Columns
Observed Churn Rate
Classification Target
The original dataset includes customer identifiers, demographic attributes, credit information, banking products, account balance, estimated salary, engagement, and the churn target.
A dedicated validation layer was introduced before model training to verify the structure and quality of incoming data.
The modeling pipeline generates additional customer-level features designed to capture financial value, engagement, product usage, and customer tenure relationships.
The supervised learning workflow uses Scikit-Learn and Imbalanced-Learn pipelines. Numerical variables are standardized, categorical variables are encoded, and SMOTE is applied within the training pipeline to address class imbalance.
| Model | Role |
|---|---|
| Logistic Regression | Interpretable baseline and quantitative probability analysis |
| Decision Tree | Rule-based classification and nonlinear splits |
| Random Forest | Ensemble-based classification |
| Gradient Boosting | Boosted-tree prediction and risk-scoring workflow |
| XGBoost | Gradient-boosted tree benchmark |
Models are evaluated using multiple complementary metrics rather than relying on accuracy alone.
Model performance is compared using classification, ranking, and probability-quality metrics.
Overall classification performance
Positive prediction quality
Churn detection sensitivity
Ranking discrimination
Additional evaluation includes F1-score, PR-AUC, log loss, Brier score, confusion-matrix metrics, and threshold optimization.
The complete comparison is stored in the project's
artifacts/metrics/model_comparison.csv
artifact.
The platform also incorporates unsupervised learning to identify groups of customers with similar demographic, financial, product, and engagement characteristics.
K-Means clustering was evaluated across multiple values of K. Cluster quality was assessed using Silhouette Score, Calinski-Harabasz Score, Davies-Bouldin Score, and inertia.
PCA-based visualization is also included to provide a two-dimensional representation of customer segments.
The platform converts model predictions into a structured customer-risk framework by combining churn probability with customer value.
Customers are categorized into Low, Medium, High, and Critical risk groups based on predicted churn probability.
The risk engine estimates the potential financial exposure associated with customer churn.
Treatment effectiveness and retention cost assumptions are explicitly configurable business assumptions rather than parameters learned directly from the churn dataset.
Risk scoring is combined with customer value to determine which customers may warrant different levels of retention attention.
Explainability was incorporated to make model predictions more transparent to analysts and business stakeholders.
These tools help analysts investigate which characteristics contribute to a customer's predicted churn risk.
Because churn probabilities are subsequently used in financial risk calculations, the project also evaluates probability quality rather than treating classification accuracy as sufficient.
Calibration analysis helps assess whether predicted probabilities correspond reasonably to observed outcomes.
The project includes a dedicated monitoring layer designed to simulate production machine-learning operations.
The trained model is exposed through a FastAPI application that provides structured prediction endpoints.
The API includes validation, health monitoring, prediction logging, model information, and monitoring-related functionality.
Supabase is used as a persistent data layer for customer risk and prediction information.
The application can retrieve customer risk-scoring records containing customer attributes, churn probability, risk category, customer value, expected loss, retention economics, and retention priority.
MLflow is incorporated into the project for experiment tracking and model lifecycle management.
GitHub Actions is used to automate validation of the application whenever changes are pushed to the repository.
The automated test suite covers API endpoints, validation behavior, feature engineering, and customer-value logic.
model_comparison.csv —
supervised model evaluation
customer_segments.csv —
customer segmentation results
customer_risk_scoring.csv —
customer-level risk and financial analysis
shap_global_importance.csv —
global explainability results
shap_local_explanations.csv —
customer-level explanations
calibration_metrics.csv —
probability calibration analysis
feature_drift_report.csv —
feature drift analysis
performance_comparison.csv —
model performance monitoring
prediction_drift_report.json —
prediction monitoring
The platform connects predictive modeling with business decision support. Instead of stopping at a churn prediction, the system provides a framework for understanding customer risk, customer value, potential financial exposure, and retention economics.
This enables analysts and business teams to move from descriptive customer analysis toward proactive, data-driven retention planning.