الانتقال إلى المحتوى
Machine Learningتقييم الموديلات· 6 دقائق للقراءة

The 0.5 Threshold Isn't Part of the Model: Tuning the Decision Cut-Off

A classifier learns probabilities; the cut-off is a business decision applied afterward. Set it from what each mistake costs, without retraining.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
  • scikit-learn 1.9
محتويات المقال

A lending team reviews its default-risk model after a bad quarter. On a test month it missed 417 applicants who later defaulted, and declined only 48 good ones. The ticket that follows reads "Model too lenient: retrain with class weights and collect more defaults", sized at two sprints. Nobody asks where the line between "approve" and "decline" is drawn. It's drawn at 0.5, by default, and moving it takes one line of code.

The common misconception

Many developers treat the 0.5 threshold as part of the model: it's what predict uses, so getting different decisions must mean training a different model. It's an easy belief to hold:

  • predict returns labels directly. The cut-off appears nowhere in the call, so it feels built in.
  • Tutorials fix lopsided decisions by changing the training: class weights, resampling, more data.
  • 0.5 sounds principled: predict "yes" when "yes" is more likely than "no".

The half-truth: 0.5 is the best cut-off in one specific situation, when the probabilities are trustworthy and both mistakes cost the same. Very few products are in that situation, and a lender certainly isn't.

What actually happens

A binary classifier does two separate things: it estimates how likely each case is to be positive, and then a rule turns that estimate into a decision. Only the first part is learned.

0.5 is a rule applied after the model

scikit-learn's guide to threshold tuning says it directly: class predictions come from hard-coded cut-off rules, a probability above 0.5 from predict_proba or a score above 0 from decision_function, and those rules are most certainly not ideal for most use cases. Training never looks at them. LogisticRegression fits its weights by minimizing log loss over the probabilities; no appears anywhere in that process. The fitted model is the probability function. The threshold is a policy you put on top.

The right cut-off comes from costs

Take an applicant with a probability p of defaulting. Approving them costs, on average, p times the price of a default. Declining them costs 1 − p times the price of losing a good customer. If a missed default costs five times a wrong decline, declining is cheaper whenever 5p > 1 − p, which means whenever p > 1/6. In general the cut-off is the cost of a false positive divided by the sum of both costs. Elkan's paper on cost-sensitive learning derives this and points out that, for decisions, any 2×2 cost matrix reduces to that single number. 0.5 is simply the answer when both costs are equal.

Python
from sklearn.datasets import make_classificationfrom sklearn.linear_model import LogisticRegressionfrom sklearn.metrics import confusion_matrixfrom sklearn.model_selection import train_test_splitX, y = make_classification(n_samples=10_000, n_features=10, n_informative=4,                           weights=[0.8], class_sep=0.7, random_state=2)X_tr, X_te, y_tr, y_te = train_test_split(X, y, stratify=y, random_state=0)model = LogisticRegression().fit(X_tr, y_tr)tn, fp, fn, tp = confusion_matrix(y_te, model.predict(X_te)).ravel()print(f"cutoff 0.5: {fp} declined good, {fn} missed defaults")print(f"cost {fp + 5 * fn}")  # a missed default costs 5x a wrong decline# cutoff 0.5: 48 declined good, 417 missed defaults# cost 2133

The same fitted model, with the cut-off moved to 1/6, brings the cost of mistakes down from 2133 to 1390, about a third less. It declines more good applicants and misses far fewer defaults, which is the trade the costs asked for. FrozenEstimator makes the point explicit: calling fit on the wrapper doesn't touch the trained weights.

TunedThresholdClassifierCV gets there without the formula. It tries cut-offs across internal 5-fold cross-validation, scores each with the business cost, and lands on 0.187, with the same test cost of 1390. Its default scorer is balanced accuracy, so pass your own: the cut-off is only as good as the metric it optimizes.

When the formula and the data disagree

The two methods agree here because the cost formula assumes probabilities, and logistic regression tends to produce them: scikit-learn's calibration guide credits its log loss and logit link. Many models don't. The same guide shows naive Bayes pushing probabilities toward 0 and 1, and random forests and SVMs pulling them toward the middle. Class weights and resampling shift probabilities on purpose. With any of those, a 0.2 isn't a 20% chance, so the formula's cut-off is off. Tune the cut-off on validation data instead, or calibrate the model first.

One model, many cut-offs

Because the cut-off sits outside the model, one model can serve several decisions: auto-decline above a high cut-off, send a middle band to manual review, approve the rest. When the costs change, say a new collections policy or a review team with half the capacity, you change a number, not the model. Google's Crash Course frames the threshold the same way: a value you choose based on which mistake is worse for your problem.

MythReality
0.5 is part of the trained modelIt's a hard-coded rule in predict; training never sees it
A different cut-off needs retrainingSame frozen model, cut-off 1/6: cost 2133 → 1390
0.5 is the neutral choiceIt's optimal only when both mistakes cost the same
The cost formula always gives the answerOnly with calibrated probabilities; otherwise tune on validation data
One model means one decision ruleOne model can drive several cut-offs for different actions

How to apply it in your project

  1. Price both mistakesAgree with the business on what a false positive and a false negative cost, even roughly.
  2. Start from the formulaWith calibrated probabilities, the cost of a false positive divided by both costs is a sound first cut-off.
  3. Tune it on validation dataUse TunedThresholdClassifierCV with a scorer built from your costs, or a curve computed on a validation split.
  4. Ship the cut-off with the modelWrap the trained model in FixedThresholdClassifier(FrozenEstimator(model), threshold=...), and version both.
  5. Revisit when costs changeNew prices, capacity or policy mean a new cut-off. Recompute it on recent data; the model can stay.

Key takeaways

  • A classifier learns probabilities; 0.5 is a rule applied to them afterward.
  • Moving the cut-off needs no retraining: the same model's cost fell from 2133 to 1390.
  • The right cut-off comes from costs: false-positive cost over the sum of both, for calibrated probabilities.
  • Tune it on validation data, never on training data, and version it with the model.

📚 المصادر

  1. Tuning the decision threshold for class prediction — scikit-learn User Guide
  2. Post-tuning the decision threshold for cost-sensitive learning — scikit-learn examples
  3. Classification: Thresholds and the confusion matrix — Google Machine Learning Crash Course
  4. Elkan, The Foundations of Cost-Sensitive Learning (IJCAI 2001)
  5. Probability calibration — scikit-learn User Guide

التعليقات (0)