Topic 6 of 6 · 5 min read
Choosing a metric for the business decision
Goal: Pick the primary metric and threshold for a use case from the cost of each error type.
Choose the metric and the threshold by writing down what each kind of error costs the business, then pick the setting that minimises the total cost or meets the stated limit. The best metric is the one your decision actually depends on, not the one the library prints first.
Check yourself · 1 of 3
What should come first when choosing a metric for a model?
Why it matters
The same model is excellent for one job and harmful for another. A detector with 95% precision and 50% recall is fine for auto-flagging content for human review; it is not enough for a safety system that must not miss anything. Skipping this step is how teams optimise F1 and then wonder why the business is unhappy.
A method
- Name the decision. Who acts on the prediction, and what do they do? "Call the customer", "block the payment", "show the ad".
- Cost each error. False positive: what does a wasted call, a blocked good customer or a needless test cost? False negative: what does a missed fraud, a missed fault or a lost customer cost? Rough numbers are enough; ratios matter more than precision.
- Check for a capacity limit. If reviewers can handle 200 cases a day, you need the top 200 scores, which is a precision-at-k question.
- Pick the metric that mirrors it. Recall at a minimum precision, precision at a fixed volume, expected cost, MAE in units for stock, RMSE when big misses are costly.
- Set the threshold on validation data and recheck it when volumes or costs change.
cost_fp, cost_fn = 5, 200 # a call versus a lost customer
def cost(th):
pred = scores >= th
fp = ((pred == 1) & (y == 0)).sum()
fn = ((pred == 0) & (y == 1)).sum()
return fp * cost_fp + fn * cost_fn
best = min(thresholds, key=cost)
Before and after
Before: "Our target is F1 above 0.8." After: "A missed churner costs about 40 times a retention call. We want recall of at least 0.85, with precision as high as possible, within 600 calls a week." That sentence rules out most models and tells the team which curve to look at.
What goes wrong
- Metric chosen before the decision. The model is then tuned for a number nobody uses.
- Equal costs by default. F1 and accuracy assume false alarms and misses cost the same.
- Stale costs. A threshold tied to last year's prices or staffing is wrong now.
- A metric the team can game. If the proxy rises while the real outcome does not, such as clicks without sales, change the metric.
- No guard on harm. Add a floor for a metric that must not fall, such as recall on the smallest segment.
Examples
Cost-based threshold
A bank blocks suspected card fraud. A false alarm costs about 3 in support time; a missed fraud costs about 150. With these numbers, one miss is as costly as 50 false alarms, so the best threshold flags generously and accepts low precision. Computing total cost at each threshold on validation data finds the cheapest point instead of defaulting to 0.5.
Capacity-limited review
A moderation team can review 300 posts a day. The model scores 20,000 posts. The question is how many of the top 300 are truly harmful, which is precision at 300, together with how much harm is outside that top 300. Overall F1 cannot answer either.
Key points
- Start from the decision someone will make with the prediction, then choose the metric that matches it.
- Estimate the cost of a false positive and a false negative, even roughly; their ratio steers the threshold.
- A capacity limit such as reviewer hours turns the problem into precision at the top k scores.
- F1 and accuracy assume equal error costs, which is rarely true.
- Re-check the threshold when costs, volumes or the population change.
Common mistakes
- Picking F1 or accuracy first and the decision second.
- Assuming a false positive and a false negative cost the same.
- Ignoring reviewer or call capacity when setting the threshold.
- Leaving a threshold unchanged after the costs or the user base changed.
Check yourself · 2 of 3
Missing a faulty part costs 500 and an unnecessary inspection costs 10. What does that suggest for the threshold?
Check yourself · 3 of 3
A team can review 100 flagged cases a day. Which metric fits best?
Practice items, not counted towards your mastery.
Start here
- Google ML Crash Course: classification (opens in a new tab)CourseFree
Accuracy, precision, recall and ROC/AUC explained with worked confusion-matrix numbers.
- scikit-learn: metrics and scoring (opens in a new tab)DocsFree
The reference for every metric named in this skill, with the exact function and its edge cases.
- scikit-learn: probability calibration (opens in a new tab)DocsFree
Reliability curves, Brier score and the sigmoid and isotonic recalibration methods, with plots.