Overview
Headline numbers for the modelled population of 7,032 customers after cleaning, plus the best classification performance achieved.
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.
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.
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.
| Metric | LR baseline | RF baseline | LR optimised | RF optimised |
|---|---|---|---|---|
| Accuracy | 80.5% | 78.7% | 75.3% | 74.6% |
| Precision | 65.0% | 62.3% | 52.6% | 51.5% |
| Recall | 57.2% | 50.3% | 73.5% | 75.1% |
| F1-score | 60.9% | 55.6% | 61.3% | 61.1% |
| ROC-AUC | 83.6% | 81.7% | 83.5% | 82.0% |
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.
| Churners caught (TP) | — |
| Churners missed (FN) | — |
| Loyal customers flagged (FP) | — |
| Loyal customers kept (TN) | — |
| 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.
| Feature | Coefficient | Direction |
|---|---|---|
| tenure | -1.3558 | reduces churn |
| Contract_Two year | -1.3512 | reduces churn |
| InternetService_Fiber optic | +1.1217 | increases churn |
| Contract_One year | -0.7435 | reduces churn |
| TotalCharges | +0.6418 | increases churn |
| PhoneService_Yes | -0.5229 | reduces churn |
| MonthlyCharges | -0.4452 | reduces churn |
| PaymentMethod_Electronic check | +0.3863 | increases churn |
| StreamingTV_Yes | +0.3749 | increases churn |
| OnlineSecurity_Yes | -0.3708 | reduces churn |
| Feature | Importance |
|---|---|
| TotalCharges | 0.1943 |
| tenure | 0.1685 |
| MonthlyCharges | 0.1680 |
| InternetService_Fiber optic | 0.0389 |
| PaymentMethod_Electronic check | 0.0379 |
| Contract_Two year | 0.0319 |
| gender_Male | 0.0289 |
| OnlineSecurity_Yes | 0.0273 |
| PaperlessBilling_Yes | 0.0256 |
| Partner_Yes | 0.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