Learn/Evaluation/Lesson 6
Chapter 3 · Choose metrics, objectives, and policy

Metric selection by task and decision

Select metrics from the prediction target, decision, error costs, prevalence, slices, horizon, and deployment constraints—not from habit.

65–90 min7 key conceptsReviewed 26 Aug 2026
01 · Production proposition

Teams report excellent accuracy, RMSE, mAP, or perplexity while the fraud queue, forecast, defect review, and assistant outcomes get worse.

This lesson isolates metric selection by task and decision as one decision inside that system. The people affected are product users and operators; the learning data must carry event time, availability time, ownership, and version; and the operating envelope is the decision latency, review capacity, horizon, and cost envelope for the task.

Decision

Choose the smallest metric set that measures model discrimination, probability/uncertainty quality, decision utility, and system constraints.

Metric

A versioned metric contract with direction, unit, aggregation, slices, uncertainty, threshold, guardrails, and stop conditions.

Failure consequence

Teams report excellent accuracy, RMSE, mAP, or perplexity while the fraud queue, forecast, defect review, and assistant outcomes get worse. An unsafe release must degrade to a named baseline or the last known-good version.

02 · Intuition & prerequisites

Build the mental model before the machinery.

The core move is to treat metric selection by task and decision as a contract between data, a computation, and an action. Every model card names why each metric matches the action, which aggregation and horizon it uses, required slice/uncertainty views, and the threshold or policy that turns scores into outcomes. The implementation becomes easier to debug once you can state which inputs exist, which state is learned, what output means, and what must remain invariant after serialization.

01

metric contracts

Define it in a hand-checkable form and name the prediction-time inputs.

02

proper scoring rules

Connect it to the production metric and identify what it cannot guarantee.

03

prevalence sensitivity

Stress it with a slice, a temporal boundary, and a failure-safe alternative.

04

ranking metrics

Stress it with a slice, a temporal boundary, and a failure-safe alternative.

05

forecast scale

Stress it with a slice, a temporal boundary, and a failure-safe alternative.

06

slice reliability

Stress it with a slice, a temporal boundary, and a failure-safe alternative.

07

decision utility

Stress it with a slice, a temporal boundary, and a failure-safe alternative.

Bring forward

Lessons 1, 2, 3, 4, 5 in this course.

03 · Formal treatment

Name every symbol. Check every shape.

Cost-weighted harmonic mean of precision and recall is the central invariant for this lesson. The formula is useful only when its inputs match the production cutoff and its output maps to an action.

Formal treatment
Fβ=(1+β2)precisionrecallβ2precision+recallF_\beta = \frac{(1 + \beta^2)\,\mathrm{precision}\,\mathrm{recall}}{\beta^2\,\mathrm{precision} + \mathrm{recall}}

Cost-weighted harmonic mean of precision and recall

Symbol, shape or unit contract
SymbolMeaning / shape / unit
βrelative weight placed on recall
precisionfraction of positive decisions that are correct
recallfraction of actual positives recovered
F_βone summary at a declared threshold
Open derivation and numerical substitution

Start from the production quantity being optimized, substitute the observed values with their declared units, then isolate the model-controlled term. Preserve shape annotations at each step so broadcasting or aggregation cannot silently change the result.

  1. Write the named inputs: β, precision, recall, F_β.
  2. Substitute one small, hand-checkable batch before vectorizing.
  3. Calculate an independent reference value and compare within a declared tolerance.
# equation → code contract
inputs = validate_shapes_and_units(batch)
value = compute_c02(inputs)
assert is_finite(value)
04 · Selection field guide

Choose from the task contract, not a favorite default.

There is no universally best metric.

Start from the decision, harm, target semantics, prevalence, aggregation unit, horizon, and operating constraint. Keep one primary metric, complementary diagnostics, and production guardrails.

Task-to-metric decision map
TaskPrimary starting pointPair withProduction guardrailsNever use alone
Binary probabilityLog loss or Brier score; calibration errorPR-AUC for rare positives; ROC-AUC as discrimination contextPrecision, recall, utility, and queue volume at the operating thresholdAccuracy or AUC alone
Hard classificationBalanced accuracy, MCC, or justified FβPer-class confusion matrix; macro and micro viewsCost by slice, abstention, latency, and fallback outcomesOne aggregate accuracy
Multiclass / multilabelMacro and per-label precision/recall/F1Micro metrics and top-k only when product semantics fitCoverage, calibration, rare-label behavior, and policy capacityMicro average alone
RegressionMAE for linear error cost; RMSE for large-error sensitivityR² only against a meaningful baseline; quantile error when asymmetricResidual slices, bias, uncertainty, and action costA metric chosen without units
ForecastingMASE or scale-aware error by horizon; biasPinball loss and interval coverage/widthInventory or staffing cost, horizon slices, and driftMAPE near zero or one pooled horizon
Ranking / searchNDCG@k for graded order; MRR for first-hit tasksRecall@k for candidate generation; MAP when relevant-set semantics fitCoverage, diversity, freshness, position slices, latency, and online utilityOffline clicks treated as unbiased relevance
Anomaly detectionPrecision or analyst yield at alert budgetEvent recall, false alerts per time unit, detection delayIncident cost, alert fatigue, novelty slices, and investigation latencyROC-AUC on extreme imbalance
DetectionmAP across IoU thresholds, classes, sizes, and slicesRecall at an operating confidence thresholdCalibration, duplicate rate, review load, and device latencyOne mAP number
SegmentationPer-class IoU or Dice plus boundary qualityPixel-level precision/recall and calibration where usefulSmall-object slices, topology failures, latency, and correction effortPixel accuracy on background-heavy masks
ClusteringStability and downstream/operator utilityARI or NMI only when trustworthy labels exist; silhouette as a diagnosticCoverage, actionability, drift, and manual validationInternal geometry declared product success
Language generationTask success, groundedness, factuality, and safetyToken loss/perplexity as an intrinsic diagnostic; calibrated judge or human preference with auditCitation validity, refusal behavior, latency, cost, and adversarial slicesPerplexity or one opaque judge score
05 · Three views of the idea

Calculate it small. Shape it realistically. Break it on purpose.

HAND-CALCULATED TOY

A result you can reproduce on paper

Two classifiers are 95% accurate on a 5% positive dataset. One predicts every row negative; the other recovers 70% of positives at 50% precision. Compare accuracy, PR behavior, and action cost.

  1. Write every input and unit.
  2. Substitute values into the cost-weighted harmonic mean of precision and recall equation above.
  3. Compare the result to one simple baseline and explain the direction of the difference.
PRODUCTION-SHAPED

The same reasoning under real constraints

Create a metric contract for fraud, demand forecasting, retrieval, segmentation, and language generation that names a primary decision metric, calibration or uncertainty measure, slice views, and system guardrails.

The production record includes the data snapshot, transformation state, artifact identity, cutoff, score, decision, and the version of the policy that consumed it.

FAILURE / COUNTEREXAMPLE

The attractive result you should reject

A team chooses ROC-AUC for rare-event review, MAPE with near-zero targets, pixel accuracy for tiny defects, and perplexity as the only assistant launch metric.

Diagnostic: replay the smallest failing slice from immutable inputs, then compare each boundary rather than retuning the model.

06 · Deterministic lab

Change one assumption and make the tradeoff visible.

This lab runs predefined TypeScript only. It never executes learner code. Use the slider, numeric input, reset, live text, or table—the computation is the same.

Exact computation

Cost-aware threshold

Move the cutoff over a fixed set of scored transactions.

Primary16 cost
Secondary4 caught
Diagnosis2 false alerts

Assumption: Fixed 12-event dataset; false positive costs 2 units and false negative costs 12.

Open nonvisual data table
ItemComputed stateInterpretation
0.92fraudreview
0.84fraudreview
0.76legitreview
0.68fraudreview
0.59legitreview
0.51fraudreview
0.43legitpass
0.37legitpass
0.31fraudpass
0.22legitpass
0.14legitpass
0.08legitpass
07 · Production implications

Trace the complete operating path.

  1. 01

    Validate and version metric contracts.

  2. 02

    Compute metric selection by task and decision from prediction-time-safe inputs.

  3. 03

    Persist model, feature, and configuration identities together.

  4. 04

    Serve or materialize behind explicit the decision latency, review capacity, horizon, and cost envelope for the task.

  5. 05

    Join telemetry to mature outcomes and retain a rollback path.

Observability

Join service health, input quality, prediction distributions, slice behavior, and mature outcomes by exact version.

Cost

Measure storage, preprocessing, compute, queueing, and human review under a representative arrival pattern.

Failure modes

A team chooses ROC-AUC for rare-event review, MAPE with near-zero targets, pixel accuracy for tiny defects, and perplexity as the only assistant launch metric. Add a detector, owner, mitigation, and stop condition for this class of failure.

Alternatives

Compare a rule, a simpler statistical baseline, and a different system boundary before adding model complexity.

07 · Check understanding

Explain the contract, not just the vocabulary.

Browser-graded checkpointPass ≥ 80%
01Which metric is universally best for classification?
02Why can MAPE fail for demand forecasting?
03What should accompany an aggregate ranking metric?
08 · Apply in production

Metric-contract portfolio

Write complete selection contracts for rare fraud, ETA regression, search ranking, and visual defect detection.

  • Primary metric and decision rationale for four tasks
  • Secondary diagnostics, thresholds, and guardrails
  • Aggregation, horizon, slice, and uncertainty definitions
  • Counterexample where each selected metric misleads
  • Release and rollback decision template
Production self-review0/100

Staged hints

Failure diagnosis

  • If offline numbers look impossible, audit prediction-time availability before model code.
  • If quality is sound but the contract fails, measure the exact serialized and served path.
  • If one slice regresses, preserve that slice as a permanent release gate.

Record an honest attempt to unlock the reference solution.

09 · Sources & next depth

Read primary material with a purpose.

10 · Production resolution

Return to the opening failure.

Every model card names why each metric matches the action, which aggregation and horizon it uses, required slice/uncertainty views, and the threshold or policy that turns scores into outcomes.

For this lesson, the release evidence is a hand-checked formal result, deterministic simulation output, a ≥80% checkpoint, the production rubric, and a named fallback. The course resolves when the system can produce a metric contract, leakage-safe validation, calibration analysis, and experiment plan.

Course production assignmentLate-delivery evaluation contract