A churn model with class weights counted 6,867 departures instead of the real 2,150
The predict_proba method returns numbers between 0 and 1, and people treat them as probabilities. But ROC AUC only checks the ordering of customers. On a 60,000-row dataset with 11% churn, a class-weighted regression counted 6,867 departures against the real 2,150, roughly three times as many. A 0.3 threshold selected 47% of customers, yet only 20% of them actually left. If the number feeds a budget, check calibration first.
AI-processed from Хабр: Машинное обучение; edited by Hamidun News
Imagine a team has trained a churn model, and the business asks not for "will leave or not" labels but for probabilities. The logic is clear: call customers with risk above 0.3, and calculate expected losses as the probability multiplied by the customer's revenue.
In code, it's a single line with the predict_proba method from scikit-learn, and from there its numbers flow into the CRM, reports, and the retention budget. The problem is that these numbers only look like probabilities. In an experiment shared on Habr, a model with class weights (a technique that makes the rare class count for more) counted 6,867 departures, while in reality 2,150 customers left.
The error is threefold, and the quality metric looked excellent the whole time.
Why ROC AUC says nothing about probabilities
Models are usually evaluated with ROC AUC. This metric measures whether the model has correctly ordered customers from less risky to more risky. It doesn't check at all whether the numbers resemble the actual frequency of events.
For the experiment, the author took a synthetic dataset of 60,000 rows with a positive class share of about 11%, similar to churn or fraud tasks, and five standard models from scikit-learn 1.9. All of them ranked reasonably well, but their numbers diverged from reality to very different degrees. For one model, a "probability of 0.43" corresponded to an actual event in only 6% of cases.
The quickest check takes one line: the average of the predicted probabilities on the test set should match the share of the positive class. For ordinary logistic regression, both numbers equal 0.109. If a model predicts 35% churn while 11% actually leave, the projected losses are inflated threefold, even when every customer is placed in the right position on the list.
Class weights and sampling shift the probabilities
The advice class_weight="balanced" appears in almost every tutorial on imbalanced data. It does help recall (the share of leaving customers found), and the weighted regression's AUC is even higher: 0.858 versus 0.845. But each positive example carries roughly 8 times the weight of a negative one, and the model learns as if leaving customers were eight times more common. Its numbers describe that imaginary dataset, not your customer base.
The calibration curve shows this immediately: a prediction of 0.12 corresponds to an actual share of 0.02, a prediction of 0.43 to 0.06, and 0.57 to 0.10. On this model, a 0.3 threshold selected 47% of the test sample, that is 9,306 customers, and the real churn among them was 20%. Summing the probabilities gave 6,867 departures against a real 2,150. The call center would receive a list four times longer than needed, and finance would budget losses three times higher than the real ones. Undersampling the majority class and SMOTE produce the same effect.
If the balance must still be changed, the shift can be removed analytically: the model's odds are multiplied by the ratio of the real odds to those the model was trained on. After this correction, the mean became 0.103, and the Brier score (the mean squared difference between probability and outcome) fell from 0.136 to 0.060. The same 0.3 threshold now selected 1,638 customers, or 8% of the sample, with a real churn of 71%. Summing the probabilities gave 2,032 departures against a real 2,150.
Different models miscalibrate in different directions
Even without weights, models are calibrated differently. The author took objects with predicted probabilities between 0.85 and 0.95 and checked how many were actually positive. For logistic regression, that's 99% (271 objects), for random forest 99% (746), for gradient boosting 98% (361). For naive Bayes, only 72% (425 objects).
The causes differ. A forest's probability is the share of trees voting for the class, and trees rarely all agree. So a forest almost never outputs values near 1 and understates its confidence. Naive Bayes multiplies the contributions of features, treating them as independent, and counts correlated features several times, which inflates its confidence. Boosting with log loss is usually well calibrated, since it optimizes that loss directly, but on small data or under strong regularization it can drift too.
What to do in practice
- Keep the Brier score alongside AUC: it penalizes both bad ordering and bad calibration.
- Build calibration curves using quantile bins, not uniform ones. With imbalance, uniform top bins contain only a handful of objects, and the curve jumps around with noise.
- For an already trained model, fit a calibrator on a sample the model has not seen: CalibratedClassifierCV(FrozenEstimator(model), method="isotonic"). FrozenEstimator appeared in scikit-learn 1.6 and replaced the deprecated cv="prefit", although the internet is full of old examples.
- AUC barely changes after calibration: for the forest it is 0.950 versus 0.949, because isotonic regression preserves the ordering of objects.
There are limitations too. The author had about 10,000 rows for calibration. The scikit-learn documentation advises against isotonic calibration when data is substantially below a thousand rows: it overfits, and on small samples the simpler sigmoid method is more reliable.
If the model is only needed for ranking ("call the 500 riskiest customers"), calibration changes nothing, because the order stays the same. It matters where the number is used as a number: expected losses by segment, a fixed threshold, comparing two models, explaining to a client that "0.7 means seven out of ten." It also matters when switching models: a threshold of 0.3 tuned for the old regression cannot be carried over to a new boosting model without verification.
- May 16, 2026Elon Musk's SpaceXAI Has Lost More Than 50 Employees Since the SpaceX–xAI Merger
- Jul 17, 2026Three OpenAI Stargate Executives Move to Meta Amid the AI Race
- Apr 30, 2026Elon Musk Vows to Rebuild xAI After Another Wave of Co-Founder Departures
- Apr 21, 2026OpenAI Academy explains how customer success teams use ChatGPT to cut churn
Key Questions Answered
Why ROC AUC says nothing about probabilities?
Models are usually evaluated with ROC AUC. This metric measures whether the model has correctly ordered customers from less risky to more risky. It doesn't check at all whether the numbers resemble the actual frequency of events. For the experiment, the author took a synthetic dataset of 60,000 rows with a positive class share of about 11%, similar to churn or fraud tasks, and five standard models from scikit-learn 1.9.
What are the key details on Class weights and sampling shift the probabilities?
The advice class_weight="balanced" appears in almost every tutorial on imbalanced data. It does help recall (the share of leaving customers found), and the weighted regression's AUC is even higher: 0.858 versus 0.845. But each positive example carries roughly 8 times the weight of a negative one, and the model learns as if leaving customers were eight times more common. Its numbers describe that imaginary dataset, not your customer base.
What are the key details on Different models miscalibrate in different directions?
Even without weights, models are calibrated differently. The author took objects with predicted probabilities between 0.85 and 0.95 and checked how many were actually positive. For logistic regression, that's 99% (271 objects), for random forest 99% (746), for gradient boosting 98% (361). For naive Bayes, only 72% (425 objects). The causes differ. A forest's probability is the share of trees voting for the class, and trees rarely all agree.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Waitlist: free vibecoding intensive + AI digest
Leave your email to reserve a spot in the free 2-day intensive and get the AI stories that matter.