Machine Learning · Classification

Telco Customer Churn

Which subscribers are about to leave, and what should the business do about it? Every figure on this page is recomputed from the raw dataset at build time — nothing is hard-coded.

Dataset Kaggle - Telco Customer Churn (IBM) Rows 7,043 raw → 7,032 modelled Features 30 Split 80/20 stratified

Overview

Headline numbers for the modelled population of 7,032 customers after cleaning, plus the best classification performance achieved.

Customers analysed
7,032
11 rows dropped
Churn rate
26.6%
1,869 customers churned
Monthly recurring
$455,661
sum of current bills
Lifetime billed
$16,056,169
sum of TotalCharges
Avg. monthly charge
$64.80
median $70.35
Avg. tenure
32 mo
median 29 mo
Best ROC-AUC
83.5%
optimised LR
Churners caught
73.5%
recall, 275 of 374

Data quality & cleaning

7,043 raw records arrive with 21 columns. TotalCharges is stored as text and arrives blank for 11 customers (all with zero tenure, i.e. cancelled before the first bill), so those rows are dropped rather than imputed. customerID is a unique key and carries no signal, so it is removed.

Raw records
7,043
21 columns
Dropped
11
blank TotalCharges
Modelled
7,032
20 features pre-encoding
Feature matrix
30
after one-hot + scaling

The split is 5,625 train / 1,407 test, stratified on the target. Feature scaling is fitted on the training rows alone and then applied to both, so no information from held-out customers leaks into the model's inputs. The one-hot encoding is done before the split, which is safe: it derives only the category vocabulary, never the target.

Exploratory analysis

Distribution of the target, the two numeric drivers, and the numeric correlation structure.

Tenure is the single clearest separator: churn collapses after year one.

Churn drivers

Churn rate by each categorical segment, sorted highest to lowest. Bars above the segment average are highlighted; contract mix is shown stacked.

Model performance

Logistic Regression and Random Forest, each trained twice: once on the raw (majority-dominated) labels and once with class_weight="balanced" plus a tuned decision threshold. AUC is threshold-independent, so it is effectively unchanged by the balancing — what moves is the precision/recall operating point.

Leakage controls. The StandardScaler is fitted on the 5,625 training rows only — the 1,407 held-out rows never contribute to its mean or standard deviation. Each decision threshold is chosen by 5-fold stratified out-of-fold cross-validation on the training split, never on the test set, so the reported metrics are an honest estimate of performance on unseen customers. Out-of-fold F1 was 63.8% (LR) and 61.9% (RF) at the selected thresholds; the test figures below are lower, which is the expected generalisation gap.

Test-set metrics — best value in each row highlighted. Thresholds are out-of-fold tuned on the training split.
Metric LR baselineRF baseline LR optimisedRF optimised
Accuracy80.5%78.7%75.3%74.6%
Precision65.0%62.3%52.6%51.5%
Recall57.2%50.3%73.5%75.1%
F1-score60.9%55.6%61.3%61.1%
ROC-AUC83.6%81.7%83.5%82.0%
Optimised operating points (out-of-fold thresholds), test set (n=1,407)

Decision threshold simulator

Move the slider to re-evaluate the held-out customers at any churn-probability cut-off. Counts update live from the stored test-set predictions, so you can see the precision/recall trade-off and the revenue consequences directly. The thresholds marked as optimal were selected by out-of-fold cross-validation on the training split — they are not fitted to this test set, so what you see here is what you would get on new customers.

jump to F1-optimal threshold
Precision
—
Recall
—
F1
—
Accuracy
—
Recall
Confusion matrix
Churners caught (TP)—
Churners missed (FN)—
Loyal customers flagged (FP)—
Loyal customers kept (TN)—
Campaign impact
Customers to contact—
Annual revenue protected—
Annual revenue in offers to loyal customers—

Revenue figures are annualised from each customer's MonthlyCharges × 12 and are indicative only — they assume a successful retention offer is worth one year of revenue and do not net off contact costs.

Feature importance

The two views agree on the drivers. Logistic Regression additionally gives the direction of each effect; the forest gives an importance ranking but no sign.

Logistic regression — standardised coefficients
FeatureCoefficientDirection
tenure-1.3558reduces churn
Contract_Two year-1.3512reduces churn
InternetService_Fiber optic+1.1217increases churn
Contract_One year-0.7435reduces churn
TotalCharges+0.6418increases churn
PhoneService_Yes-0.5229reduces churn
MonthlyCharges-0.4452reduces churn
PaymentMethod_Electronic check+0.3863increases churn
StreamingTV_Yes+0.3749increases churn
OnlineSecurity_Yes-0.3708reduces churn
Random forest — Gini importance
FeatureImportance
TotalCharges0.1943
tenure0.1685
MonthlyCharges0.1680
InternetService_Fiber optic0.0389
PaymentMethod_Electronic check0.0379
Contract_Two year0.0319
gender_Male0.0289
OnlineSecurity_Yes0.0273
PaperlessBilling_Yes0.0256
Partner_Yes0.0233

Recommended actions

Mapped from the strongest statistical signals above to concrete retention plays.

  • Contract type — Month-to-month customers churn at roughly 15x the rate of two-year subscribers (42.7% vs 2.9%), and contract length is one of the two strongest coefficients in the model. Loyalty discounts on annual commitment
  • Tenure — Risk is heavily front-loaded: churn peaks in the first year of service (53.3% in months 0-6) and declines steadily to 6.6% past five years, making early-life cohorts the highest-yield target. Onboarding programme for first 6 months
  • Internet service — Fibre-optic subscribers churn at nearly twice the rate of DSL customers, and the effect survives after controlling for tenure and spend. Audit fibre service quality
  • Payment method — Electronic-check payers churn far more often than card or bank-transfer customers, the most frictionless of the four methods. Promote auto-pay enrolment
  • Monthly spend — Higher monthly charges correlate with higher churn, indicating customers are price-sensitive at the upper end of the tariff range. Tiered pricing / loyalty rewards
  • Model deployment — The optimised Logistic Regression is preferred for deployment: near-equal ROC-AUC to the forest, better precision and F1 at comparable recall, and a fully interpretable, CRM-cheap scoring step. Score monthly in the CRM