Decisions & trade-offs

A Threshold Is a Decision

Keep the model. Change the rule. See who gets a different decision and what those mistakes cost.

8 min to exploreMachine Learning · BSAD 720
01 / UNDERSTAND

What changes when the scores stay the same, but the decision threshold moves?

A score is not a decision. A threshold turns a score into an action, and the costs of mistakes help determine which actions make sense.

02 / EXPLORE

Make a prediction.
Then move a control.

01 / Change the decision
0.50
Predict positive when score ≥ threshold
A false positive always costs 1 unit.
Try a threshold

12 positive and 12 negative examples; neither side is perfectly separated.

True positive classTrue negative classWrong decision┆ Threshold
75.0%Accuracy
75.0%Precision
75.0%Recall
75.0%Specificity
75.0%F1 score
18Error cost · units
Confusion matrix · counts
Predicted +Predicted −
Actual +9True positive3False negative
Actual −3False positive9True negative

Same scores. Different consequences.

At 0.50, 9 of 12 positives are detected and 3 negatives are incorrectly flagged.

3 misses × 5 + 3 false alarms × 1 = 18 units

Changing the cost changes the consequences of errors. At a fixed threshold, it leaves the predictions and accuracy unchanged.

Inspect every example and decision
CaseReference classScorePredictionOutcome
Discuss

If missing a positive becomes more costly, which direction would you move the threshold? What would you measure before deploying that change?

Invented examples for learning. Scores are illustrative rankings, not verified probabilities. Any threshold chosen from these examples would still require evaluation on separate data.

An educational experiment with illustrative data. The controls run locally in your browser.

03 / SEE THE CODE

The idea,
in Python.

A compact implementation of the core concept. Open the code when you are ready to connect the visual to the algorithm.

Open the core implementation Python ↗
Standalone example · illustrative valuesDownload .py
import numpy as np

# Illustrative scores: use validation data to choose a threshold.
y = np.array([1, 0, 1, 0, 1, 0])
scores = np.array([0.90, 0.80, 0.65, 0.45, 0.30, 0.10])
threshold = 0.50
pred = scores >= threshold

tp = np.sum(pred & (y == 1))
fp = np.sum(pred & (y == 0))
fn = np.sum(~pred & (y == 1))
tn = np.sum(~pred & (y == 0))
cost_fp, cost_fn = 1, 5
print({"TP": tp, "FP": fp, "FN": fn, "TN": tn})
print("Error cost:", cost_fp * fp + cost_fn * fn)
04 / TRY IT

Explain the change.
Test your reasoning.

  1. Start at a threshold of 0.50. Which type of mistake is more common?
  2. Lower the threshold. Explain the change in false positives and false negatives.
  3. Make a missed positive more costly. Separate what changes in the decisions from what changes in their evaluation.
← All visual labsNext: ROC & Precision–Recall Explorer

Find your next idea.

Search across courses, research, projects, and resources.

Ideas, connected.esc to close