A production-ready machine learning pipeline to predict customer churn in the telecommunications industry. This project demonstrates end-to-end ML workflow including data preprocessing, feature engineering, model training, evaluation, and deployment-ready model artifacts.
Business Problem: Identifying customers likely to churn helps businesses take proactive retention measures, reducing revenue loss.
- Best Model: Logistic Regression
- ROC-AUC Score: 0.8458
- Accuracy: 80.41%
- F1-Score: 0.5929
- Source: Telco Customer Churn Dataset
- Size: 7,043 customers
- Features: 20 (demographic, account, and service information)
- Target: Churn (Yes/No)
- Churn Rate: ~26.5%
- Demographics: Gender, Senior Citizen, Partner, Dependents
- Account Info: Tenure, Contract type, Payment method
- Services: Phone, Internet, Online Security, Tech Support, etc.
- Charges: Monthly charges, Total charges
- Language: Python 3.8+
- ML Libraries: scikit-learn, XGBoost, imbalanced-learn
- Data Processing: Pandas, NumPy
- Visualization: Matplotlib, Seaborn
- Model Persistence: Joblib
python >= 3.8
pip- Clone the repository
git clone https://github.com/misrapk/churn-prediction-ml.git
cd churn-prediction-ml- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Download dataset from Kaggle and place in
data/folder
- Run EDA:
jupyter notebook notebooks/01_eda.ipynb- Train Models:
jupyter notebook notebooks/03model_training.ipynb- Use Preprocessor (standalone):
python src/data_preprocessing.py- Handled missing values in
TotalCharges - Created engineered features:
tenure_group: Categorized tenure into binsavg_monthly_per_tenure: Average spending ratenum_services: Count of subscribed services
- Encoded categorical variables (Label Encoding & Binary Encoding)
- Scaled numerical features using StandardScaler
Trained and compared 5 models:
- Logistic Regression (baseline)
- Decision Tree
- Random Forest
- Gradient Boosting
- XGBoost
- Accuracy
- Precision
- Recall
- F1-Score
- ROC-AUC (primary metric for imbalanced data)
Selected [Your best model] based on highest ROC-AUC score, balancing precision and recall for business needs.
- Contract Type is the strongest predictor - month-to-month contracts have 3x higher churn
- Tenure inversely correlates with churn - customers with <12 months tenure churn most
- Monthly Charges - higher charges correlate with increased churn
- Tech Support subscription reduces churn by 40%
- Implement hyperparameter tuning (GridSearchCV/RandomizedSearchCV)
- Handle class imbalance with SMOTE/undersampling
- Build REST API with FastAPI for model serving
- Add CI/CD pipeline for automated retraining
- Deploy on AWS/Azure as web service
- Create Streamlit dashboard for predictions
- Feature engineering significantly improved model performance (+8% ROC-AUC)
- Class imbalance handling crucial for churn prediction
- Tree-based models outperform linear models for this problem
- Business context matters - optimizing for recall may be more valuable than accuracy
Peeyush K Misra
- LinkedIn: peeyushkmisra
- GitHub: @misrapk
- Email: peeushkmisra@gmail.com
This project is licensed under the MIT License - see the LICENSE file for details.
- Dataset provided by IBM Watson Analytics
- Inspired by real-world telecom churn challenges


