Sub topic 3
Estimating performance from predicted probabilities
This chapter assumes you know binary classification metrics (accuracy, precision, recall, ROC AUC), basic pandas and scikit-learn, and train/validation/test splits. You also need a prediction log that stores each model score.
Estimating accuracy from calibrated scores
If a model's scores are calibrated, a score of 0.8 means about 80 percent of cases with that score are truly positive. You can then estimate accuracy without labels. A positive call is correct with probability p, and a negative call is correct with probability 1 - p. The mean of these values is the expected accuracy.
import numpy as np
def expected_accuracy(p_positive, threshold=0.5):
p = np.asarray(p_positive, dtype=float)
predicted_positive = p >= threshold
p_correct = np.where(predicted_positive, p, 1.0 - p)
return float(p_correct.mean())
scores = [0.9, 0.2, 0.6, 0.4]
print(round(expected_accuracy(scores), 3)) # 0.725Reweighting labeled data under covariate shift
Covariate shift means the input distribution changes while the relation between inputs and outcomes stays the same. Train a domain classifier to tell old reference rows from new rows. Its output gives density-ratio weights. Weighted accuracy on the labeled reference rows then estimates accuracy on the new traffic. This holds only if P(y|x) has not changed, which features alone cannot confirm.
Learning to predict the model's own error
Train a second model on labeled history to predict whether the main model is wrong for each input. The average of its predicted error estimates the live error rate. Its own errors grow when the inputs shift, so check it against matured cohorts.
Spending a labeling budget where it helps most
Labels cost money, so send them to the predictions the model is least sure about, or to segments with high drift. Uncertainty-based sampling biases naive metrics. Weight each sampled row by the inverse of its inclusion probability when you compute performance.
Backtesting estimates once labels arrive
When labels mature, compare each earlier estimate with the observed metric for the same cohort. Track the gap across many past windows. If the gap stays within a tolerance you set in advance, the estimator is reliable for that segment. A gap that widens over time means the estimator itself has drifted.
Alerting and reconciling estimates with ground truth
Alert on the label-free estimate when it falls below a floor, and on drift signals. When matured labels arrive, reconcile the two. If they differ by more than the tolerance, alert the owner and stop trusting the estimator for that segment until it is recalibrated.
Exercise
A segment's estimated accuracy is 0.82, but backtesting against matured labels shows 0.71. What should you do?
Show answer
Stop trusting the estimator for that segment, recalibrate or refit it, alert the segment owner, and keep tracking the gap on each new matured cohort.