A machine learning project that predicts the probability of bank customer churn and provides an interactive risk-scoring dashboard using Streamlit.
Customer churn can affect revenue stability, customer lifetime value, and long-term banking relationships. This project uses historical customer data to identify patterns associated with churn and build a model that estimates the probability of a customer leaving.
The project was developed as part of a Unified Mentor internship project.
- Predict whether a bank customer is likely to churn.
- Generate a customer-level churn probability.
- Identify the most influential churn-related features.
- Compare multiple machine learning models.
- Provide an interactive dashboard for churn risk assessment.
- Demonstrate simple what-if analysis for customer engagement and product usage.
The dataset contains 10,000 European bank customer records.
Exited = 0→ Retained customerExited = 1→ Churned customer
- CreditScore
- Geography
- Gender
- Age
- Tenure
- Balance
- NumOfProducts
- HasCrCard
- IsActiveMember
- EstimatedSalary
CustomerId and Surname were excluded because they are identifiers. Year was also excluded because it did not provide meaningful variation for the model.
- Retained customers: 7,963
- Churned customers: 2,037
- Overall churn rate: 20.37%
Four additional features were created:
-
Balance-to-Salary Ratio
Balance / EstimatedSalary
-
Product Density
NumOfProducts / (Tenure + 1)
-
Engagement × Product Interaction
IsActiveMember × NumOfProducts
-
Age × Tenure Interaction
Age × Tenure
Three classification models were compared:
- Logistic Regression
- Random Forest
- Gradient Boosting
The dataset was split using an 80:20 stratified train-test split.
| Model | Accuracy | Precision | Recall | F1 Score | ROC-AUC |
|---|---|---|---|---|---|
| Gradient Boosting | 87.05% | 79.13% | 49.39% | 60.82% | 86.74% |
| Random Forest | 86.50% | 77.51% | 47.42% | 58.84% | 85.41% |
| Logistic Regression | 80.60% | 57.04% | 18.92% | 28.41% | 77.35% |
Gradient Boosting was selected as the final model because it achieved the strongest overall performance.
The most influential features in the final Gradient Boosting model were:
| Rank | Feature | Importance |
|---|---|---|
| 1 | Age | 0.387126 |
| 2 | Number of Products | 0.285662 |
| 3 | Engagement × Product Interaction | 0.067163 |
| 4 | Balance | 0.063198 |
| 5 | IsActiveMember | 0.058565 |
| 6 | Geography: Germany | 0.053754 |
| 7 | Balance-to-Salary Ratio | 0.023583 |
| 8 | Credit Score | 0.017604 |
| 9 | Estimated Salary | 0.015288 |
| 10 | Gender: Male | 0.010199 |
These values represent the model's relative feature importance and should not be interpreted as causal effects.
- Overall churn rate was 20.37%.
- Germany had the highest observed churn rate at 32.44%.
- Spain had a churn rate of 16.67%.
- France had a churn rate of 16.15%.
- Inactive members had a churn rate of 26.85%, compared with 14.27% for active members.
- Churned customers were older on average: 44.84 years versus 37.4