π’ 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
- Understand how classification differs from regression and how logistic regression works.
- Train a churn model and obtain probabilities.
- 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).
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:
- 0.5 is the default, but it is almost never optimal for the business;
- retention can call only the top 5000 customers β take the top N by probability, no threshold needed at all;
- choosing a threshold is a business decision about the balance of errors (details in module 6).
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.