Skip to content

Latest commit

ย 

History

History
94 lines (50 loc) ยท 1.95 KB

File metadata and controls

94 lines (50 loc) ยท 1.95 KB

๐Ÿ”ฎ Customer Churn Prediction

This project predicts customer churn (likelihood of a customer leaving a bank) using machine learning. It combines data analysis, feature engineering, classification models, and deployment through both Flask API and Streamlit UI.

๐Ÿ“Š Features

๐Ÿ“ˆ Exploratory Data Analysis (EDA): heatmaps, distributions, churn insights

๐Ÿ›  Feature Engineering: log transformations, interaction terms, binning

๐Ÿค– Machine Learning Models: Logistic Regression, Decision Tree, KNN

โšก Model Pipelines: preprocessing + training with scikit-learn

๐Ÿ’พ Model Persistence: trained model saved as churn_model.pkl

๐ŸŒ Flask API: REST endpoint for churn prediction (/predict)

๐ŸŽ› Streamlit UI: user-friendly interface to input customer details and predict churn

โš–๏ธ Imbalance Handling: SMOTE + class weighting for better recall

๐Ÿ› ๏ธ Tech Stack

Python 3.9+

Pandas โ€“ data handling

Matplotlib , Seaborn โ€“ visualization

Scikit-learn โ€“ ML models & pipelines

Imbalanced-learn โ€“ SMOTE for imbalance

Joblib โ€“ model saving

Flask โ€“ API deployment

Streamlit โ€“ interactive dashboard

๐Ÿš€ Installation & Setup

Clone the repository

git clone https://github.com/your-username/churn-prediction.git cd churn-prediction

Install dependencies

pip install -r requirements.txt

Run EDA / Training script

python project.py

Run Flask API

python app.py

Visit โ†’ http://127.0.0.1:5000

Example API request:

curl -X POST http://127.0.0.1:5000/predict -H "Content-Type: application/json"
-d '{"CreditScore":600,"Geography":"France","Gender":"Male","Age":40,"Tenure":5, "Balance":60000,"NumOfProducts":2,"HasCrCard":1,"IsActiveMember":1,"EstimatedSalary":50000}'

Run Streamlit App

streamlit run app_streamlit.py

Visit โ†’ http://localhost:8501

๐Ÿ“Š Model Evaluation

Metrics used: Accuracy, AUC, Confusion Matrix, Precision-Recall

Threshold tuning for better balance between precision & recall

Visual outputs: ROC & Precision-Recall curves