31 / Predictive analytics
Classification thresholds, error costs and review capacity
A probability model becomes a business policy only when a threshold or allocation rule turns its scores into actions. Confusion matrices, precision, recall and explicit error costs show the consequences of that policy. A default 0.5 threshold is rarely an economic law.
The business question
Which predicted risks should trigger action when mistakes have different costs?
- Choose an inspection threshold for orders likely to contain a fault.
- Compare fraud-review or cancellation-risk policies against available review capacity.
- Evaluate a classifier using the consequences of errors rather than accuracy alone.
How the method works
At a chosen threshold, predicted positives are the cases flagged for action. Comparing these flags with known outcomes produces true positives, false positives, false negatives and true negatives. Precision describes the proportion of flags that are genuine positives; recall describes the proportion of actual positives that were flagged. Both change as the threshold moves.
Lowering the threshold generally catches more positives and flags more negatives. Whether that is worthwhile depends on the cost of unnecessary action, the loss from a missed event and the capacity needed to investigate the extra flags. Accuracy can hide these trade-offs, especially when the event is rare. A model that predicts no faults can look accurate while failing to find the cases the business cares about.
Use a validation sample to select the rule, then freeze it before evaluating on a separate test or future period. A retrospective error-cost table is not proof that acting on the flags improves outcomes: inspection quality, treatment effectiveness and disruption need separate measurement. Calibrated probabilities can support expected-loss decisions, but ranking quality alone does not guarantee reliable probabilities.
The calculation
| Symbol | Meaning |
|---|---|
| TP, FP | Correctly flagged positives and incorrectly flagged negatives. |
| FN, TN | Missed positives and correctly unflagged negatives. |
| C_FP | Cost assigned to an unnecessary flag in the stated model. |
| C_FN | Cost assigned to a missed event in the stated model. |
A worked business example
ILLUSTRATIVE SCENARIO
Illustrative held-out order-inspection data contain four genuine faults among ten orders.
Inputs
- Actual fault labels: 1,0,1,0,0,1,0,0,1,0.
- Risk scores: 0.90,0.80,0.70,0.60,0.55,0.45,0.40,0.30,0.20,0.10.
- Assume R50 per false positive and R300 per false negative; compare thresholds 0.50 and 0.30.
Work through the numbers
- At 0.50: TP=2, FP=3, FN=2, TN=3; precision=2/5=0.40 and recall=2/4=0.50.
- The illustrative error cost is 3×R50+2×R300=R750, with five orders flagged.
- At 0.30: TP=3, FP=5, FN=1, TN=1; precision=3/8=0.375 and recall=3/4=0.75.
- The error cost is 5×R50+1×R300=R550, but eight orders now require attention.
That option is infeasible if only six reviews can be completed, and this comparison does not establish the globally optimal threshold or future savings. Review effort, correct-case treatment cost and actual intervention benefit are outside the simple error-cost model.
Explore the decision
Connect classification errors to cost. The live explorer has its own example inputs; it is separate from the worked calculation above.
Enable JavaScript to use this calculator. The worked example and executable Python remain available.
Apply it at work
- Define the prediction target, action, relevant error costs and maximum workable review load.
- Generate scores on data excluded from fitting and preserve a separate final evaluation period.
- Compare candidate thresholds using confusion counts, capacity, calibration and the chosen business objective.
- Pilot the selected action policy and monitor realised outcomes, costs, subgroup performance and drift.
Check these assumptions
- Evaluation outcomes are reliable and sufficiently mature, and the sample represents the intended decision population.
- Scores are generated without leakage from labels or later information.
- The stated cost model and operational capacity describe the actual decision closely enough to be useful.
- Threshold tuning is separated from the final performance assessment.
Common mistakes and how to avoid them
- Choosing the best-looking threshold on the final test set turns that set into tuning data.
- Reporting accuracy alone can hide a near-total failure to detect rare but costly events.
- Treating predicted risk as preventable loss assumes an intervention works, which must be evaluated separately.
How this can help the business
- An inspection manager can see the extra workload purchased by a higher detection rate before changing the policy.
- A finance team can compare plausible error costs and actual pilot outcomes instead of relying on one statistical score.
Select an action rule that meets the measured cost, capacity and quality requirements on representative validation data, then confirm it on an untouched or later evaluation sample.
When to use another approach
Use capacity-based top-k review, cost-sensitive learning, decision-curve analysis or an experiment that estimates which customers actually benefit from intervention.
Reproduce the worked example in Python
The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.
Show executable code and recorded output
import numpy as np
from sklearn.metrics import confusion_matrix, precision_score, recall_score
actual = np.array([1,0,1,0,0,1,0,0,1,0])
probability = np.array([.9,.8,.7,.6,.55,.45,.4,.3,.2,.1])
for threshold in [.5,.3]:
predicted = probability >= threshold
tn, fp, fn, tp = confusion_matrix(actual, predicted).ravel()
cost = fp*50 + fn*300
print("Threshold:", threshold, "TP/FP/FN/TN:", tp, fp, fn, tn)
print("Precision/recall:", round(precision_score(actual,predicted),3), round(recall_score(actual,predicted),3), "Cost R:", cost)Recorded output
Threshold: 0.5 TP/FP/FN/TN: 2 3 2 3 Precision/recall: 0.4 0.5 Cost R: 750 Threshold: 0.3 TP/FP/FN/TN: 3 5 1 1 Precision/recall: 0.375 0.75 Cost R: 550
Sources and further reading
Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.