Threshold Moving
A classifier’s score and its final action are separate objects. Threshold moving changes the action rule while leaving the fitted score model unchanged. It can reduce missed positives, limit false alarms or meet another operating objective.
This chapter uses the same ten ranked cases as the evaluation chapter. We first select a threshold from validation outcomes. Later, we derive a cost-based cutoff for scores that can be interpreted as probabilities.
State the rule, including equality
Let $s(x)$ be the score for an observation $x$, with higher scores indicating stronger evidence for the positive class. Choose a threshold $t$ and write $\hat y$ for the predicted label:
We include a score exactly equal to the threshold. Other code may use a strict comparison; that difference matters when scores are tied. A threshold of 0.5 is a common default for probability predictions, but arbitrary decision scores have no universal cutoff at 0.5.
Lowering the threshold can only add alerts to this fixed score list. Recall cannot decrease, and the number of false positives cannot decrease. Precision need not change monotonically: the next group admitted might contain more positives or more negatives.
Choose against a stated validation objective
The validation scores, from highest to lowest, are [0.95, 0.90, 0.80, 0.70, 0.60, 0.55, 0.40, 0.30, 0.20, 0.10]. Their true labels are + − + − − + − − − −. These scores establish a ranking; we have not established that they are calibrated probabilities.
Assign cost 4 to a missed positive and cost 1 to a false alarm; correct decisions cost zero. At threshold 0.80, we detect two positives, miss one and raise one false alarm. Total cost is 4 × 1 + 1 × 1 = 5. At 0.55, we detect all three positives with three false alarms, costing 3.
A + is an actual positive; a − is an actual negative. Highlighted cases trigger an alert.
Changing the miss cost can change the preferred threshold. With miss cost 1, detecting only the highest-scoring case costs 2; accepting more alerts has no lower cost in this example. Lowering the threshold is a tradeoff, not an automatic improvement.
Search where the predictions actually change
For a finite validation set, predictions change only when the threshold crosses a distinct score. Evaluate those score cutoffs and one cutoff above the maximum, which predicts everything negative. Under our ≥ rule, a cutoff at the minimum score already includes the all-positive decision.
For cost 4, any threshold greater than 0.40 and at most 0.55 gives the same predictions here. The displayed 0.55 is a representative of that interval, not a uniquely precise parameter. Tied scores enter as a group because the model cannot rank them internally.
If the objective is a capacity limit or a minimum recall, first reject thresholds that violate the constraint, then compare the feasible choices. Sometimes no threshold satisfies all requirements. Randomly breaking ties or allowing partial review is a separate policy that needs its own evaluation.
Tune on validation predictions, then freeze the rule
Cross-validation can supply held-out predictions when data are limited. Scikit-learn’s TunedThresholdClassifierCV automates threshold tuning; its default objective is balanced accuracy, so set a scorer that matches your actual goal. With cv="prefit", the data used to choose the threshold must be separate from the data that trained the supplied classifier.
Changing the threshold does not change ROC AUC, AP or the underlying scores. It moves the operating decision along the existing curves. Refitting a model, changing class weights or recalibrating scores can change the score scale, so do not assume a threshold selected for one fitted system transfers unchanged to another.
When the score really is a probability
Now suppose $p$ estimates the probability that this case is positive in the intended population. Let $C_{\mathrm{FP}}$ be the cost of a false alarm and $C_{\mathrm{FN}}$ the cost of a miss, both positive, with zero cost for correct decisions.
Predicting positive is wrong only when the case is negative, with probability $1-p$. Predicting negative is wrong only when the case is positive, with probability $p$. Their expected costs are therefore
Choose positive when its expected cost is no larger. Rearranging $(1-p)C_{\mathrm{FP}}\le pC_{\mathrm{FN}}$ gives
This 0.20 rule assumes meaningful probabilities for the population being served. It is not a replacement for the empirical 0.55 cutoff on the earlier arbitrary scores. Check probability calibration, and account for a review-capacity constraint separately if one exists.
References and further reading
- Scikit-learn: tuning the decision threshold — score-versus-decision separation, scorer selection and held-out threshold tuning.
- Charles Elkan: The Foundations of Cost-Sensitive Learning — choosing actions by expected cost and deriving probability thresholds from a cost matrix.
- Scikit-learn: probability calibration — checking whether scores can be interpreted as event probabilities.