Customer churn prediction is one of the most important applications of machine learning in the telecom industry. Telecom companies lose significant revenue when customers discontinue services, and retaining existing customers is substantially cheaper than acquiring new ones.
This project builds a complete industry-style machine learning pipeline capable of predicting customer churn using customer demographics, billing information, and subscribed services.
The system was designed with a strong focus on:
- production-ready preprocessing,
- handling class imbalance,
- recall optimization,
- explainability,
- business-oriented evaluation.
The primary objective is to identify customers who are likely to churn before they leave the company.
This allows businesses to:
- launch targeted retention campaigns,
- reduce customer loss,
- improve customer satisfaction,
- increase long-term revenue.
Customer churn datasets are naturally imbalanced.
Most customers:
- stay with the company,
- while only a smaller percentage churn.
This creates a major challenge:
A model can achieve very high accuracy simply by predicting:
“Most customers will not churn.”
However, such a model becomes useless from a business perspective because it fails to identify actual churners.
In this project, the primary optimization metric is:
Recall measures:
how many actual churn customers were correctly identified.
This is critical because:
If the model fails to detect a churner:
- the customer leaves,
- revenue is lost,
- retention opportunity disappears.
Therefore:
✔ maximizing churn recall is more important than maximizing raw accuracy.
Dataset Used:
The dataset contains:
- demographic information,
- account information,
- billing behavior,
- subscribed services,
- churn labels.
Raw Data
↓
Data Cleaning
↓
Feature Engineering
↓
Preprocessing Pipeline
↓
Model Training
↓
Threshold Optimization
↓
Evaluation & Explainability
↓
Model Export (Joblib)
- Missing value handling
- Scaling
- One-hot encoding
- Pipeline API (ColumnTransformer)
- Logistic Regression
- Random Forest
- XGBoost (Best Model)
- Accuracy
- Precision
- Recall
- F1-score
- ROC Curve
- Confusion Matrix
| Model | Accuracy | Churn Recall |
|---|---|---|
| Logistic Regression | 74% | 79% |
| Random Forest | 78% | 68% |
| XGBoost | 75% | 80% |
Best performance for churn detection due to highest recall.
The final trained machine learning pipeline is saved using Joblib for real-world deployment.
- Saves full ML pipeline (preprocessing + model)
- Enables reuse without retraining
- Used in production systems
- Supports deployment in APIs / apps
import joblib
joblib.dump(xgb_pipeline, "customer_churn_pipline/models/churn_pipeline.pkl")import joblib
model = joblib.load("customer_churn_pipline/models/churn_pipeline.pkl")
predictions = model.predict(X_test)- Confusion Matrix
- ROC Curve
- Precision-Recall Curve
- Feature Importance
- Contract type strongly impacts churn
- Higher monthly charges increase churn risk
- New customers are more likely to churn
- Python
- Pandas
- NumPy
- Scikit-learn
- XGBoost
- Matplotlib
- Joblib
✔ End-to-end ML pipeline
✔ Reusable preprocessing
✔ Model serialization (Joblib)
✔ Threshold tuning
✔ Business-focused evaluation
Name: Malik Muhammad Mudassir Iqbal
Role: Building real world production grade intelligent systems, Machine Learning Engineering
Project: End-to-End Customer Churn Prediction System
This project was built as part of an ML learning portfolio focused on:
- real-world machine learning pipelines
- production-ready model deployment practices
- business-oriented analytics
This project demonstrates a complete machine learning system for customer churn prediction using production-grade practices.
The final model is:
- accurate enough for real-world use,
- optimized for recall,
- fully deployable using joblib pipeline serialization.