File size: 4,794 Bytes
55dd5bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | # π¦ Bank Customer Churn Prediction using Artificial Neural Network (ANN)
## Overview
This project is an AI-powered **Bank Customer Churn Prediction System** developed using **Deep Learning (Artificial Neural Networks)**. The application predicts whether a customer is likely to leave the bank based on their personal and financial information.
The model is deployed using **Streamlit** and can be easily hosted on **Hugging Face Spaces** for public access.
---
## Features
* Deep Learning-based customer churn prediction
* Interactive Streamlit web interface
* Real-time predictions
* Standardized input preprocessing using StandardScaler
* Probability score for each prediction
* Clean and user-friendly interface
---
## Dataset
The project uses the **Bank Customer Churn Dataset**.
### Input Features
| Feature | Description |
| --------------- | ---------------------------------------- |
| CreditScore | Customer's credit score |
| Gender | Male or Female |
| Age | Customer age |
| Tenure | Number of years with the bank |
| Balance | Current account balance |
| NumOfProducts | Number of bank products owned |
| HasCrCard | Whether the customer has a credit card |
| IsActiveMember | Whether the customer is an active member |
| EstimatedSalary | Estimated annual salary |
### Target Variable
| Target | Meaning |
| ------ | ----------------------- |
| 0 | Customer Stays |
| 1 | Customer Leaves (Churn) |
---
## Technologies Used
* Python
* TensorFlow / Keras
* NumPy
* Pandas
* Scikit-learn
* Joblib
* Streamlit
---
## Deep Learning Architecture
* Input Layer: **9 Features**
* Hidden Layer 1: Dense Layer (ReLU)
* Hidden Layer 2: Dense Layer (ReLU)
* Output Layer: Dense Layer (Sigmoid)
### Activation Functions
* ReLU
* Sigmoid
### Loss Function
Binary Crossentropy
### Optimizer
Adam Optimizer
### Evaluation Metric
Accuracy
---
## Data Preprocessing
The following preprocessing steps were applied before training:
* Removed unnecessary columns
* Encoded Gender
* Feature Scaling using StandardScaler
* Train-Test Split
* Normalized numerical features
The trained StandardScaler is saved as:
```
scaler.pkl
```
to ensure identical preprocessing during deployment.
---
## Model Files
```
ann_model.h5
```
Trained Artificial Neural Network model.
```
scaler.pkl
```
Saved StandardScaler used during training.
```
app.py
```
Streamlit application.
---
## Project Structure
```
Bank-Customer-Churn-Prediction/
β
βββ app.py
βββ ann_model.h5
βββ scaler.pkl
βββ requirements.txt
βββ README.md
βββ dataset.csv
```
---
## Installation
Clone the repository
```bash
git clone <repository-url>
```
Move into the project
```bash
cd Bank-Customer-Churn-Prediction
```
Create Virtual Environment
```bash
python -m venv venv
```
Activate Virtual Environment
### Windows
```bash
venv\Scripts\activate
```
### Linux / macOS
```bash
source venv/bin/activate
```
Install dependencies
```bash
pip install -r requirements.txt
```
---
## Run the Application
```bash
streamlit run app.py
```
---
## How the Prediction Works
1. User enters customer information.
2. Input data is converted into numerical format.
3. Features are scaled using the saved StandardScaler.
4. The trained ANN predicts the probability of customer churn.
5. If the probability is greater than **0.5**, the customer is predicted to leave the bank; otherwise, the customer is predicted to stay.
---
## Example Prediction
### Input
```
Credit Score: 619
Gender: Female
Age: 42
Tenure: 2
Balance: 0
Products: 1
Credit Card: Yes
Active Member: Yes
Estimated Salary: 101348.88
```
### Output
```
Prediction Probability: 0.34
Customer is likely to Stay.
```
---
## Requirements
```
streamlit
tensorflow
numpy
pandas
scikit-learn
joblib
```
---
## Future Improvements
* Support Geography feature
* Explain predictions using SHAP
* Interactive analytics dashboard
* Batch prediction from CSV
* REST API using FastAPI
* Docker deployment
* Cloud deployment on AWS or Azure
---
## Deployment
This project can be deployed on:
* Hugging Face Spaces
* Streamlit Community Cloud
* Render
* Railway
* AWS EC2
* Microsoft Azure
* Google Cloud Platform
---
## Author
**Sudheer Muthyala**
B.Tech β Electronics and Communication Engineering
Aspiring Data Scientist | AI & Machine Learning Enthusiast
---
## License
This project is intended for educational and portfolio purposes. Feel free to fork, modify, and build upon it while providing appropriate attribution.
|