A machine learning project to predict customer churn in the telecom industry using Logistic Regression, Random Forest, and Support Vector Machine (SVM).
- Overview
- Dataset
- Project Structure
- Tech Stack
- How to Run
- Models Used
- Results
- Visualizations
- Future Improvements
- Team
Customer churn — when a customer stops using a service — is a critical problem for telecom companies. Retaining existing customers is significantly cheaper than acquiring new ones. This project builds a binary classification pipeline that predicts whether a customer will churn based on their usage patterns and account information.
Key goals:
- Clean and preprocess real-world telecom data
- Train and compare three ML models
- Evaluate using multiple metrics (Accuracy, F1, ROC-AUC, Log-Loss)
- Visualize EDA findings and model performance
Source: Telco Customer Churn — Kaggle
| Property | Value |
|---|---|
| Records | 7,043 customers |
| Features | 19 (numerical + categorical) |
| Target | Churn (1 = churned, 0 = stayed) |
| Churn Rate | ~26.5% |
Key features include: tenure, MonthlyCharges, TotalCharges, Contract type, InternetService, PaymentMethod, SeniorCitizen, and more.
churn-prediction/
│
├── churn_prediction.py # Main script — full ML pipeline
├── model_summary.csv # Model metrics comparison table
│
├── plots/
│ ├── 01_churn_distribution.png
│ ├── 02_boxplots.png
│ ├── 03_correlation_heatmap.png
│ ├── 04_confusion_matrices.png
│ ├── 05_roc_curve_comparison.png
│ ├── 06_learning_curve_accuracy.png
│ ├── 07_learning_curve_logloss.png
│ ├── 08_feature_importance_lr.png
│ ├── 09_feature_importance_rf.png
│ ├── 10_scatter_feature_importance.png
│ └── 11_model_summary_table.png
│
└── README.md
| Library | Purpose |
|---|---|
pandas |
Data loading and manipulation |
numpy |
Numerical operations |
matplotlib |
Plotting and visualizations |
seaborn |
Statistical visualizations |
scikit-learn |
ML models, preprocessing, evaluation |
git clone https://github.com/sanikatare/churn-prediction.git
cd churn-predictionpip install pandas numpy matplotlib seaborn scikit-learnDownload WA_Fn-UseC_-Telco-Customer-Churn.csv from Kaggle and place it in the project root.
In churn_prediction.py, replace the synthetic data section with:
df = pd.read_csv("WA_Fn-UseC_-Telco-Customer-Churn.csv")python churn_prediction.pyAll plots will be saved to the output/ directory.
A linear binary classifier that models churn probability using a sigmoid function. Simple, interpretable, and fast — but assumes linearity.
An ensemble of decision trees trained on random data subsets. Handles non-linear relationships well and is robust to overfitting.
Finds the optimal hyperplane to separate churn vs. non-churn customers. Uses an RBF kernel for non-linear classification.
| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC | Log-Loss |
|---|---|---|---|---|---|---|
| Logistic Regression | 0.7864 | 0.6289 | 0.4867 | 0.5487 | 0.8148 | 0.4527 |
| Random Forest | 0.7693 | 0.5941 | 0.4282 | 0.4977 | 0.8007 | 0.4840 |
| SVM | 0.7779 | 0.6061 | 0.4787 | 0.5349 | 0.8048 | 0.4659 |
Key takeaways:
- Logistic Regression achieved the highest ROC-AUC (0.8148) and lowest log-loss
- SVM showed competitive performance with good class separation
- Random Forest had strong recall, identifying more actual churn cases
- All models struggled with the class imbalance (~73% non-churn vs ~27% churn)
| Plot | Description |
|---|---|
| Churn Distribution | Class balance bar chart + churn by contract type |
| Box Plots | Feature distributions split by churn label |
| Correlation Heatmap | Pairwise correlations among numerical features |
| Confusion Matrices | Side-by-side for all three models |
| ROC Curve Comparison | AUC comparison across models |
| Learning Curves | Accuracy and log-loss vs. training size |
| Feature Importance | LR coefficients and RF Gini importance (top 15 features) |
- Handle class imbalance using SMOTE or class-weight adjustments
- Hyperparameter tuning with GridSearchCV or RandomizedSearchCV
- Ensemble methods — Voting Classifier or Stacking
- Deep learning — experiment with a simple neural network
- Model deployment — Flask/FastAPI REST API for real-time predictions
- Feature engineering — time-based features from tenure data
This project is for academic purposes only.