A complete customer-churn prediction project — from data preprocessing and model training, to deployment via a Streamlit web app. This project demonstrates building a full-pipeline ML solution with feature engineering, model comparison, and a user-friendly interface for real-time predictions.
The goal of this project is to predict whether a customer is likely to churn (cancel service) using historical telecom data. By training and comparing several models, and then deploying the best one, this system can help businesses identify at-risk customers and intervene proactively — improving retention and reducing revenue loss.
Churn-Prediction-System/
│
├── data/
│ └── Telco_Customer_Churn_Dataset.csv
│
├── models/
│ ├── xgb_churn_model.pkl # Trained XGBoost model
│ ├── scaler.pkl # Standard Scaler
│ └── feature_names.pkl # List of features names
│
├── .gitignore # gitignore file
├── main.ipynb # Jupyter notebook with data cleaning, EDA, model training & evaluation
├── main.py # Streamlit App
└── requirements.txt # Dependencies
| Model | Accuracy | Recall (Churn = 1) | Comments |
|---|---|---|---|
| Logistic Regression | ~72% | 81% | Good at catching churners (high recall) |
| Random Forest | ~78% | 50% | Strong overall accuracy but misses many churn cases |
| XGBoost (final) | ~75% | 78% | Balanced performance; selected as production model |
The final XGBoost model was chosen because it offered a strong trade-off between precision, recall, and overall stability after cross-validation.
git clone https://github.com/YourUsername/Churn-Prediction-System.git
cd Churn-Prediction-Systempython -m venv venv
source venv/bin/activate # (Windows: venv\\Scripts\\activate)pip install -r requirements.txtstreamlit run app.pyThen open your browser at http://localhost:8501 to access the web interface. You can input customer details (tenure, monthly charges, contract type, etc.) and get a churn prediction with probability.
Numeric features (tenure, MonthlyCharges, TotalCharges) are standardized using the saved scaler.pkl.
Categorical features (Contract, PaymentMethod, etc.) are one-hot encoded, and the resulting feature vector is aligned via feature_names.pkl to match the model’s expected input.
The trained XGBoost model in xgb_churn_model.pkl makes the prediction — either churn (1) or no churn (0) — and returns a probability score.