Course outline

Machine Learning / Prediction and data foundations / Lesson 7

Classification Thresholds and Decision Costs

Turn classification scores into decisions and compare threshold choices using a held-out evaluation.

About 3 min readContent reviewed
On this page

Lesson goals

  • Distinguish scores from thresholded decisions.
  • Count false positives and false negatives.
  • Choose thresholds with costs and capacity in mind.

Separate scores from actions

A classifier can assign a score to each case, while an operational decision requires a rule such as acting when the score is at least a chosen threshold. The score and threshold are different parts of the system. Changing the threshold changes decisions without changing the underlying model or its ranking.

A score should not automatically be interpreted as a calibrated probability. Define the positive class and specify what action follows a positive decision. For example, a review queue may have limited capacity, and both unnecessary reviews and missed cases can have costs.

Trace a small confusion matrix

The synthetic example uses four scores and known binary labels. At a threshold of 0.5, two cases are predicted positive and one of those is actually positive. The other is a false positive; the positive case with score 0.4 is a false negative. Count these outcomes before reducing them to a single metric.

python Apply one threshold
scores = [0.9, 0.7, 0.4, 0.2]
labels = [1, 0, 1, 0]
threshold = 0.5
predictions = [int(score >= threshold) for score in scores]
print(predictions)
print(sum(p == 1 and y == 1 for p, y in zip(predictions, labels)))

The predicted labels are 1, 1, 0, 0 and the true-positive count is one.

Compare candidate rules

Lowering the threshold can flag more cases, including additional true positives and false positives. In this fixture, 0.3 catches both positive cases but also flags the same negative case. The total number of errors falls from two to one; that result is illustrative and does not predict performance on other data.

python Compare errors at two thresholds
scores = [0.9, 0.7, 0.4, 0.2]
labels = [1, 0, 1, 0]
for threshold in (0.5, 0.3):
    predictions = [int(score >= threshold) for score in scores]
    errors = sum(p != y for p, y in zip(predictions, labels))
    print(threshold, errors)

The program evaluates the same four examples at each threshold, so the difference follows from the changed decision rule.

Keep selection separate from testing

Use validation data representative of the intended decision to compare thresholds, including error costs, subgroup performance, and review capacity. Then evaluate the selected threshold once on a separate test set. Choosing repeatedly against the final test set makes that test part of selection and weakens its value as independent evidence.

Monitor the decision contract

Record the model version, score meaning, positive class, threshold comparison operator, and intended action. Track counts and rates after deployment when reliable outcomes arrive, and review changes in population or available capacity. A threshold chosen under one set of conditions may no longer be appropriate; reassess with current evidence rather than silently changing it.

Common errors and fixes

A high score is described as a guaranteed probability.

Why it happens
Ranking scores and calibration were treated as identical.
How to fix it
Assess calibration on appropriate independent outcomes before interpreting probabilities.
Prevent it next time
Document the score meaning and evaluation evidence.

A threshold is chosen using the final test results.

Why it happens
The same data were used for selection and final evaluation.
How to fix it
Select on validation data and evaluate once on an untouched test set.
Prevent it next time
Define and preserve the split before tuning.

The review queue exceeds its capacity.

Why it happens
Threshold selection ignored the number of positive decisions.
How to fix it
Compare candidate thresholds with capacity and error costs.
Prevent it next time
Monitor decision volume and review the contract when capacity changes.

2 practice exercises

1. At threshold 0.5 the example predicts two positives, one correct. How many false positives and false negatives are there?

Show worked solution

One predicted positive is actually negative, so there is one false positive. The actual positive scored 0.4 and was predicted negative, giving one false negative.

2. A lower threshold catches more positive cases but doubles the review queue. What evidence is needed before adopting it?

Show worked solution

Compare false-positive and false-negative costs, queue capacity, subgroup results, and validation uncertainty on representative data. Select the rule before testing it on an untouched set and document the resulting tradeoff.

Key takeaways

  • A threshold turns scores into decisions.
  • Error costs and capacity matter alongside classification metrics.
  • Choose on validation data and evaluate separately.

Official references