Skip to content

Repository files navigation

Bank Customer Churn Prediction

This project predicts which bank customers are likely to churn and uses the model results to support customer retention decisions.

Main Features

  • Exploratory data analysis and data quality checks
  • Feature engineering and one-hot encoding
  • Logistic Regression, Random Forest, and XGBoost models
  • Hyperparameter tuning with Optuna
  • Model evaluation using Accuracy, Precision, Recall, F1-score, ROC-AUC, and PR-AUC
  • Final model selection based primarily on validation PR-AUC
  • SHAP and Partial Dependence Plot explainability
  • Customer risk scoring and single-customer prediction
  • Decile, lift, and cumulative gains analysis
  • Model-based vs random retention campaign comparison
  • Campaign channel simulation and strategic recommendations

Project Structure

Bank_Churn_Prediction/
│
├── data/
│   └── BankCustomerChurnPrediction.csv
│
├── main.py                   # Main training and evaluation pipeline
├── models.py                 # Model training, tuning, and evaluation
├── visualization.py          # Confusion matrix, ROC, and PR plots
├── explainability.py         # SHAP and partial dependence analysis
├── retention.py              # Retention and campaign simulations
├── recommendations.py        # Business recommendations
├── model_storage.py          # Save and load the final model
│
├── eda.ipynb                 # Exploratory data analysis
├── hypothesis_testing.ipynb  # Statistical hypothesis tests
├── predict.ipynb             # Single-customer churn prediction
│
├── final_churn_model.pkl     # Saved final model bundle
├── requirements.txt
└── README.md

Installation

Python 3.14 was used for the project environment.

Create and activate a virtual environment, then install the required packages:

pip install -r requirements.txt

Run the Project

From the project folder, run:

python main.py

The script trains and compares the models, selects the final model, evaluates it on the test set, creates explainability and retention analyses, and saves the final model to final_churn_model.pkl.

Notebooks

Open the notebooks with Jupyter:

jupyter notebook
  • eda.ipynb — data exploration, cleaning, anomaly checks, outliers, and churn patterns
  • hypothesis_testing.ipynb — statistical tests related to churn
  • predict.ipynb — churn probability and risk level for a single customer using the saved model

About

Machine learning project for predicting bank customer churn using Logistic Regression, Random Forest, and XGBoost. Includes EDA, model evaluation, explainability, customer risk prediction, and retention campaign impact analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages