Projects / Machine Learning
Telco Customer Churn: Analysis & Prediction
Exploratory analysis of telecom customer churn followed by classification models tuned for catching churners. A tuned LightGBM model was chosen for its recall at a 0.45 decision threshold. No business impact was measured.
- Python
- scikit-learn
- LightGBM
- XGBoost
- SHAP
- Customer records
- 7,043
- Recall (tuned LightGBM)
- 0.810at threshold 0.45
- PR-AUC
- 0.666as reported; see limitations
Visual evidence
Select any image to enlarge. Use the arrow keys to move between images.
- Dataset
- Telco customer churn dataset (public)
- Size
- 7,043 customer records, 21 features, plus derived features
- Source
- Public Telco churn dataset
- Business problem
- Dataset
- Analytical workflow
- Business insights
- Methodology and technical decisions
- Results and limitations
Business problem
Losing customers costs a telecom more than keeping them. The question was which customers are most likely to leave, which factors are associated with leaving, and whether a model could flag at-risk customers for a retention team.
Dataset
The data has 7,043 customer records with demographics, contract type, internet service, payment method, tenure and charges. Derived features such as AvgChargePerMonth and TenureGroup were added.
Limitations:
- The data carries tenure but no calendar dates, so it cannot show how churn changes over time.
- It has no cost or revenue-per-customer information for a retention campaign, so the model cannot be tied to money.
- Churners are a minority class, which affects how the model must be evaluated.
Analytical workflow
- Preparation. Encoding of categorical variables, handling of missing values and outliers, feature sets for linear and tree-based models.
- Exploratory analysis. Churn compared across tenure, gender, contract, internet service, payment method and charges.
- Diagnostics. Statistical checks on data quality and model readiness.
- Modelling. Logistic Regression, KNN, Random Forest, XGBoost and LightGBM compared.
- Tuning. A broad RandomizedSearchCV followed by a narrower GridSearchCV, optimising PR-AUC and recall.
- Explanation. Tree-based feature importance and SHAP, plus threshold analysis.
Business insights
The exploratory work points to higher churn among short-tenure customers, senior citizens, customers on month-to-month contracts and customers paying by electronic check. Model explanations point to the same area: two-year contract, tenure, fiber optic service, monthly charges, one-year contract and electronic check were among the strongest drivers.
What a retention team could consider (not tested): focus outreach on month-to-month and fiber optic customers, encourage longer contracts and automatic payment, and tailor offers to new and senior customers.
Methodology and technical decisions
- PR-AUC and recall, not accuracy. With a minority churn class, accuracy rewards predicting “no churn” for everyone. PR-AUC measures the precision-recall trade-off, and recall measures how many real churners are caught.
- Different feature sets for different models. Linear models and tree models were given suitable inputs;
TotalChargesandAvgChargePerMonthwere left out of the regression feature set, while tree-based models usedTotalCharges. - Choosing the model. Tuned XGBoost and tuned LightGBM score almost the same on PR-AUC. LightGBM was preferred because it caught more churners: recall 0.810 compared with 0.532 for XGBoost, and 0.775 for Random Forest.
- Threshold of 0.45. Chosen from threshold analysis to balance precision and recall. A different threshold would change recall.
Results and limitations
- Reported for tuned LightGBM: recall 0.810 and PR-AUC 0.666 (from the repository README).
- A discrepancy to be aware of. The tuned precision-recall chart in the repository labels LightGBM at 0.660 and XGBoost at 0.666. The two models are effectively tied on PR-AUC, which is why the choice rests on recall at the chosen threshold. The exact PR-AUC figure should be checked against the notebook.
- Higher recall means more false alarms. Precision at the 0.45 threshold is not reported on this page, and the cost of a false alarm is unknown.
- Feature importance describes what the model uses, not what causes churn.
- No business impact was measured. The model was not deployed, and no retention campaign was run.
Disclaimer. Personal portfolio project on a public dataset. The model was never deployed and no retention result was measured.
Interested in work like this?
Tell me about your data and the decision you need to make.