The Decision Threshold
The Decision Threshold — A classifier outputs scores; the decision threshold is the cut-off that turns a score into a class. Moving it trades false positives against false negatives, and the optimal threshold depends on the relative cost of each error, not a default of 0.5.
Frame it as a medical test: two overlapping score distributions and a draggable threshold. Turn the dial on how bad a miss is, and the optimal cut-off slides to match — proving 0.5 is rarely the right answer.
Extreme threshold! At one end you flag everyone, at the other no one — both useless.
- Healthy (−)
- Disease (+)
- Your threshold
- Cost-optimal
The same 10 cases, judged three ways (click a row to cut there)
| score | actual | t = 0.30 | t = 0.70 | t = 1.00 |
|---|---|---|---|---|
| 0.83 | disease | + | + | − |
| 0.73 | disease | + | + | − |
| 0.65 | disease | + | − | − |
| 0.59 | disease | + | − | − |
| 0.53 | healthy | + | − | − |
| 0.49 | disease | + | − | − |
| 0.41 | healthy | + | − | − |
| 0.31 | healthy | + | − | − |
| 0.23 | healthy | − | − | − |
| 0.14 | healthy | − | − | − |
Green is a correct call, red a wrong one. Precision and recall swap places between the two fixed columns without a single number in the model changing.
Threshold controls
The idea in plain words
A classifier outputs a score; the threshold turns that score into a decision. The default 0.5 is rarely right — the best cut-off depends on the consequences. Frame it as a medical test: missing a disease (a false negative) is usually far costlier than a false alarm.
Turn up the cost of a miss and the optimal threshold slides lower to catch more cases. It’s the same TP/FP/FN/TN tradeoff from the confusion matrix, now weighted by what each error actually costs.
Now, the math
Pick the threshold that minimizes expected cost, not error count:
- the cost of a false positive (false alarm).
- the cost of a false negative (a miss).
▸ Show the derivation
The optimal threshold is where the marginal cost of catching one more positive equals the marginal cost of the false positives it admits. As the miss cost rises, that balance point shifts down, so the model flags more cases — exactly what a screening test wants.
Trace it by hand
The same ten scored predictions from the precision-recall example — positives at 0.9, 0.8, 0.6, 0.4, 0.2 and negatives at 0.7, 0.55, 0.35, 0.25, 0.1 — now cut at t = 0.3 versus t = 0.7, then costed with a false alarm at 1 and a miss at 5. Counts and costs verified with the site's threshold engine; rounded to 2 decimals.
Low threshold, t = 0.3: cast a wide net
Everything scoring 0.3 or more is flagged — 7 points. Recall jumps to 0.8 but 3 of the 7 flags are false alarms.
High threshold, t = 0.7: only sure bets
Same model, same scores — precision rose from 0.57 to 0.67 while recall fell from 0.8 to 0.4.
Price the errors at t = 0.3
A medical-test framing: a miss costs 5 times a false alarm.
Price the errors at t = 0.7
The default t equals 0.5 lands in between at 1 times 2 plus 5 times 2 equals 12 — also beaten by the low threshold.
What just happened: Raising the threshold from 0.3 to 0.7 traded recall (0.8 down to 0.4) for precision (0.57 up to 0.67) on identical predictions. Once errors carry prices — a miss 5 times a false alarm — the comparison stops being a matter of taste: 8 versus 16, and the wide-net threshold wins by half.
Now Break It
Try this: Push the threshold to an extreme — catch everything (all positives) or nothing.
Control: Threshold slider (drag to either extreme)
What happens: Extreme threshold! At one end you flag everyone, at the other no one — both useless.
Where the decision threshold is used
The decision threshold is the cutoff that turns a model's continuous score or probability into a hard yes-or-no label, and choosing it is a business decision about consequences, not a mathematical default. Most libraries use 0.5 out of the box, but that value is rarely optimal and often actively wrong for imbalanced or cost-sensitive problems. A cancer screening tool might set a low threshold so it flags anyone with even moderate risk, accepting more false alarms to avoid missing a real case. A system that automatically blocks user accounts for suspected abuse might set a high threshold, acting only when very confident, because wrongly locking out a legitimate user is costly. The same trained model can serve very different needs simply by moving this cutoff.
The central misconception is that 0.5 is a principled, universal boundary rather than an arbitrary starting point. On imbalanced data, where the positive class is rare, the optimal threshold is frequently much lower, and picking it by hand ignores the actual costs of each error type. A better approach uses the precision-recall or ROC curve to select an operating point, or minimizes an explicit expected-cost objective that weights false positives and false negatives differently. One more caution: the threshold should be tuned on validation data and then evaluated on a separate untouched test set, because choosing the cutoff that maximizes a score on the same data you report on leaks information and inflates the result.
Frequently asked questions
Why is 0.5 not always the right decision threshold?
How do I choose a good threshold?
Does changing the threshold require retraining the model?
Should I tune the threshold on the test set?
How does the decision threshold relate to precision and recall?
Written & reviewed by the ML Visualization team · Last updated .