This project predicts which bank customers are likely to churn and uses the model results to support customer retention decisions.
- 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
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
Python 3.14 was used for the project environment.
Create and activate a virtual environment, then install the required packages:
pip install -r requirements.txtFrom the project folder, run:
python main.pyThe 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.
Open the notebooks with Jupyter:
jupyter notebookeda.ipynb— data exploration, cleaning, anomaly checks, outliers, and churn patternshypothesis_testing.ipynb— statistical tests related to churnpredict.ipynb— churn probability and risk level for a single customer using the saved model