| # π¦ 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. |
|
|
|
|