MODULE 05 Β· Junior Β· 2 hours

The insight turned out to be worth more than the model

Retention cannot call 200,000 people, it needs a ranked list. That is where the real requirement comes from: not a β€œwill churn” label but a probability.

Open this module in the simulator All 23 lessons

The first two modules are free, no card. The rest are $20/month.

🏒 The situation

Emergency sync. Max shows a chart: subscribers of the fintech product are leaving; monthly churn is 8%.

"Retaining a customer is 5Γ— cheaper than acquiring a new one. The retention team has a budget for calls and bonuses, but we can't call all 200,000 customers. Give me a list: who will leave within the next 30 days."

Lena translates it into ML language:

"Binary classification. Target: did the customer leave within 30 days (we have historical labels). Anya assembled the features: activity, payments, support tickets, tenure. Start with logistic regression β€” and understand why its output is a probability. Retention needs probabilities to rank whom to call first."

🎯 Your task

  1. Understand how classification differs from regression and how logistic regression works.
  2. Train a churn model and obtain probabilities.
  3. Deliver a ranked customer list to the business.

πŸ“š Theory

Why not linear regression?

The target is 0 or 1. Linear regression outputs arbitrary numbers (βˆ’0.3, 1.7), which cannot be read as probabilities. The solution is to wrap the linear combination in a sigmoid:

The sigmoid squeezes any number into (0, 1) β†’ the output reads as the probability of class 1: P(churn | x).

Sigmoid: Οƒ(z) = 1 / (1 + e⁻ᢻ) threshold 0.5 (not a dogma!) 0 1 0.5 z = wΒ·x + b (any number from βˆ’βˆž to +∞) z β‰ͺ 0 β†’ P β‰ˆ 0: stays z ≫ 0 β†’ P β‰ˆ 1: churns
The sigmoid squeezes any output of the linear part into (0, 1) β€” we get a churn probability we can rank customers by.

The loss function β€” log loss

MSE works poorly for classification (a non-convex surface). We use the logistic loss (cross-entropy): it heavily punishes confident mistakes β€” predicting 0.99 "stays" when the customer left β†’ a huge penalty.

The decision threshold

The model outputs a probability; the "call / don't call" decision appears after choosing a threshold:

Interpreting the coefficients

Logistic regression coefficients act on the log-odds: a positive feature weight increases the churn probability. exp(w) β€” how much the odds multiply per +1 of the feature. For the business: "every negative support ticket multiplies the odds of leaving by 1.6".

Regularization

With many features the model can overfit. L2 (Ridge) β€” pushes weights toward zero; L1 (Lasso) β€” zeroes out weak features (built-in selection). In sklearn the C parameter is the inverse regularization strength: smaller C β†’ stronger regularization.


What to remember

  • Logistic regression = a linear model + sigmoid β†’ probability.
  • Use stratify in the split when classes are imbalanced.
  • 0.5 is not a sacred threshold; the business often needs the top-N by probability.
  • Explainable coefficients are a huge plus in regulated domains (finance!).

Next in this module: Practice

Open the module β†’

Nearby lessons

04 Predicting delivery cost 06 A 99%-accurate model that doesn't work

The whole program β€” 23 lessons