Concepts and worked examples

Evaluation, ranking, and business value

Use model errors, rankings, and probabilities to make better decisions.

Count outcomes before choosing a score

Define the positive class and prediction moment first. Consider 1,000 cases containing 100 actual positives and 900 negatives. A chosen threshold gives the following counts; rows represent actual labels and columns represent predictions.

Confusion matrix at one operating threshold
Actual classPredicted positivePredicted negativeTotal
PositiveTP = 60FN = 40100
NegativeFP = 90TN = 810900
Total1508501,000

Prevalence π = positives/N = 0.10. A majority classifier that always predicts negative scores 0.90 accuracy, exceeding this model, while finding no positives. Its precision is undefined because it issues no alerts; software needs an explicit zero-division policy. Accuracy is not mathematically invalid under imbalance, but can conceal failure on the important class. F1 ignores true negatives and assumes a particular precision–recall balance rather than actual business costs.

Baselines and numeric predictions

Compare against a training-set majority classifier, a simple decision stump with one split, and an operational rule already in use. For regression, the training mean is a natural squared-error baseline; the training median is useful for absolute error. Baselines must be trained and evaluated under the same split, not given future information.

For actual values (2, 4, 6) and predictions (3, 3, 5), errors are (1, −1, −1). MAE = Σ|yᵢ − ŷᵢ|/n = 1. MSE = Σ(yᵢ − ŷᵢ)²/n = 1; RMSE = √MSE = 1 in target units. With evaluation mean 4, total squared deviation is 4 + 0 + 4 = 8, so R² = 1 − SSE/SST = 1 − 3/8 = 0.625. R² can be negative, and is undefined by this formula for a constant target. Its test-set reference mean defines the metric, not permission to train on test labels. RMSE restores units; it does not remove squared loss's sensitivity to large errors.

Turn probabilities into actions

Expected value is Σₒ P(o) × value(o). With zero cost for correct decisions, false-positive cost 5 and false-negative cost 100, acting has expected loss 5(1 − p), while not acting has loss 100p. Act when p > 5/(100 + 5) ≈ 0.0476. At p = 0.08 the losses are 4.60 versus 8.00, so acting is preferred even below probability 0.5. This assumes calibrated deployment probabilities, fixed costs, and that action produces the stated payoff.

For the matrix above, loss = 90 × 5 + 40 × 100 = 4,450. Always predicting negative loses 100 × 100 = 10,000. The model therefore improves this cost objective despite lower accuracy. Include investigation effort, intervention effectiveness, capacity, delayed outcomes, and possible harms in a real payoff matrix. With varying customer values, rank by expected incremental net benefit rather than response probability alone.

Ranking, calibration, and rare events

ROC plots TPR against FPR across thresholds. ROC AUC equals the probability that a randomly selected positive receives a higher score than a randomly selected negative, plus half the probability of a tie. It is a ranking measure, not the fraction of correct predictions or a guarantee of profitable operation. AUC near 1 is desirable for discrimination, but the relevant low-FPR region and capacity constraint can matter more than the whole area.

A precision–recall curve emphasizes performance among retrieved positives. Its baseline precision is prevalence, making PR summaries useful for rare events but population-dependent. Average precision and trapezoidal PR AUC use different interpolation conventions; report which one is used. Calibration asks whether cases assigned probability 0.2 actually become positive about 20% of the time. Inspect reliability plots, Brier score, and log loss separately from ranking. A monotone score transformation can preserve AUC while damaging calibration.

Cumulative response and lift

Suppose the top-ranked 200 of 1,000 customers contain 60 of the population's 100 responders. The targeted fraction is q = 0.20, cumulative response or gain is 60/100 = 0.60, and cumulative lift is 0.60/0.20 = 3. Equivalently, selected precision 60/200 = 0.30 divided by population prevalence 0.10 is 3. Random selection has expected gain q and lift 1. At the full population, gain and lift both reach 1. Distinguish this cumulative curve from response rate within a single score bin.

These curves require known labels and a representative or correctly weighted evaluation population. Training and test prevalence need not literally match: deployment prevalence is the quantity to represent. Balanced resampling can aid learning or diagnostic comparisons but does not make production precision 50%-prior precision. Given TPR 0.60 and FPR 0.10, production prevalence 0.01 implies precision = πTPR/[πTPR + (1 − π)FPR] = 0.006/0.105 ≈ 0.0571. At a 0.50 prior it would be 0.8571. Reweight class-conditional outcomes for the deployment prior only when the relevant within-class distributions remain applicable.

Report uncertainty and diagnose failure

Evaluate plausible prevalence, cost, and intervention-effect scenarios. Bootstrap at the independent customer or site level, preserve temporal dependence where needed, and report sample counts and uncertainty at the operating threshold. Inspect missingness, calibration, segment errors, drift, and delayed or selectively observed labels. A strong aggregate AUC can coexist with poor minority-group recall or an overloaded investigation queue. Select thresholds on validation data, not by repeatedly reading the final test.

Question: Why can precision collapse after deployment with unchanged TPR and FPR?

A lower positive base rate puts many more negatives into the alert pool. Recompute precision with deployment prevalence, audit whether class-conditional performance also shifted, and recalibrate where justified.

Question: Does the best AUC model necessarily create the highest profit?

No. Profit depends on the operating region, calibration, prevalence, heterogeneous payoffs, capacity, and intervention effects. Compare locked decision policies at realistic costs.

Review validation design and distinguish association lift from targeting lift in associations and ensembles.

Definition

View in glossary →