Sub topic 14
Alerting and reconciling estimates with ground truth
This chapter assumes you have read the earlier chapters on label maturity, matured-cohort evaluation, drift detection, calibrated performance estimation, and backtesting estimates against late labels. You should be comfortable with pandas, scikit-learn metrics, and the idea of a prediction log. Here you turn those pieces into an alerting policy that decides who gets woken up, when, and on what evidence.
Why alerting is harder with delayed labels
With immediate labels, alerting is simple: compute the metric, compare it with a threshold, and page if it falls below. With delayed labels, each signal you hold has a different flaw:
- Matured-cohort metrics are trustworthy but old. A fraud model with a 60-day chargeback window tells you today how the model performed two months ago.
- Estimated performance (calibrated-probability estimates, importance weighting, a learned error model) is fresh but carries uncertainty. It can also be wrong in ways you cannot see without labels.
- Drift signals are the freshest, but they say the inputs changed. They do not say the model got worse.
A good policy treats these as evidence of different strength and routes each to a response that fits. It does not apply one threshold to a single number.
Tiering signals by confidence and cost
| Signal | Freshness | Confidence it means "model is worse" | Suitable response |
|---|---|---|---|
| Drift on inputs or scores | Hours | Low | Dashboard flag, ticket |
| Estimated metric, uncertain or unvalidated estimator | Hours to days | Medium | Notify the owner channel |
| Estimated metric, confidently below floor, estimator backtested as trustworthy | Hours to days | High | Page, start mitigation |
| Matured-cohort metric below floor, adequate coverage | Weeks to months | Very high | Confirm incident, trigger retraining review |
Two properties of the estimate matter more than its point value:
- Its uncertainty. Alert on the interval, not the point. If the floor is 0.85 and the estimate is 0.84 with a half-width of 0.04, you do not know the model is below the floor. If the estimate is 0.80 with a half-width of 0.02, you do.
- Its track record. An estimator earns the right to page people only after backtests show it agrees with matured labels. Without that record, cap its severity at "notify".
Reconciling estimates with ground truth
Reconciliation is the step where labels arrive and you compare them with what you said earlier. For each cohort, store the estimate you published at the time. When the cohort matures, compute the true metric and record the error: estimate - matured.
Do three things with that record:
- Score the estimator. Track the mean error (bias) and the worst recent error. A bias that stays near zero is good. A large bias or one big miss means the estimator's assumptions are broken. Common causes are calibration decay, a change in P(y|x), or covariate shift outside the support of the reference data.
- Downgrade or restore trust. Trust is a state that changes. If recent errors exceed a tolerance, the estimator drops to notify-only. It goes back to paging only after it has agreed with labels again over several cohorts.
- Close the loop on past alerts. Mark each earlier alert as confirmed, false alarm, or missed. These counts are your precision and recall for the alerting system itself.
Keep the original estimate immutable. If you overwrite it with the matured value, you lose the data needed to score the estimator.
A reference implementation
The code below encodes the policy: matured evidence outranks estimates, an estimator must be backtested as trustworthy before it can page, and uncertainty is taken into account. It uses only the standard library and NumPy.
from dataclasses import dataclass
from typing import List, Optional
import numpy as np
@dataclass
class CohortReport:
cohort: str # e.g. "2026-W40"
estimate: float # label-free metric estimate, stored when published
halfwidth: float # uncertainty of the estimate
drift: bool # did a drift detector fire for this cohort?
matured: Optional[float] = None # true metric, filled in once labels mature
coverage: float = 0.0 # fraction of the cohort with mature labels
def estimator_trusted(history: List[CohortReport],
tolerance: float = 0.03,
min_cohorts: int = 4) -> bool:
"""True if the estimator agreed with matured labels on recent cohorts."""
errors = [r.estimate - r.matured for r in history if r.matured is not None]
if len(errors) < min_cohorts:
return False
recent = np.array(errors[-min_cohorts:])
return bool(abs(recent.mean()) <= tolerance
and np.abs(recent).max() <= 2 * tolerance)
def decide(current: CohortReport,
history: List[CohortReport],
floor: float = 0.85,
min_coverage: float = 0.8,
tolerance: float = 0.03) -> str:
# 1. Ground truth outranks any estimate, if the cohort is mature enough.
if current.matured is not None and current.coverage >= min_coverage:
if current.matured < floor:
return "page: confirmed below floor on matured labels"
return "ok: confirmed on matured labels"
# 2. Otherwise rely on the estimate, scaled by how much we trust it.
upper = current.estimate + current.halfwidth
lower = current.estimate - current.halfwidth
trusted = estimator_trusted(history, tolerance)
if trusted and upper < floor:
return "page: estimate confidently below floor"
if lower < floor:
return "notify: estimate may be below floor (trusted=%s)" % trusted
if current.drift:
return "ticket: drift without estimated degradation"
return "ok"
good_history = [
CohortReport("w1", 0.90, 0.02, False, matured=0.89, coverage=0.95),
CohortReport("w2", 0.89, 0.02, False, matured=0.90, coverage=0.95),
CohortReport("w3", 0.91, 0.02, False, matured=0.90, coverage=0.95),
CohortReport("w4", 0.88, 0.02, False, matured=0.89, coverage=0.95),
]
bad_history = [
CohortReport(r.cohort, r.estimate, r.halfwidth, r.drift,
matured=r.estimate - 0.08, coverage=0.95)
for r in good_history
]
now = CohortReport("w9", estimate=0.80, halfwidth=0.02, drift=True)
print(decide(now, good_history)) # page: estimate confidently below floor
print(decide(now, bad_history)) # notify: estimate may be below floor (trusted=False)The same current estimate produces a page or a notification depending only on the estimator's track record. That is the intended behavior.
The decision flow
Setting the floor and the intervals
- Derive the floor from cost. A floor like "AUC below 0.85" is arbitrary unless you can say what the business loses below it. Where possible, express it in cost terms, such as expected missed fraud per week, and convert it back to a metric.
- Use one floor per cohort grain. If you evaluate weekly cohorts, a floor calibrated on monthly data will have a different variance. Small cohorts have wide intervals and will rarely page, which is correct behavior.
- Use the estimator's own interval. For confidence-based estimation, bootstrap the predictions in the cohort. For importance weighting, include the effect of clipped weights, which shrink the effective sample size. Report that effective sample size alongside the estimate.
Failure modes
- Alert fatigue from drift. Drift detectors fire often on seasonal changes. Keep drift at ticket level unless an estimate agrees that performance has dropped.
- Flapping. An estimate that hovers around the floor produces on-off alerts. Require the condition to hold for two consecutive cohorts, or add hysteresis: page at 0.85, clear only at 0.87.
- Correlated failure. If calibration decays, both the calibrated-probability estimate and a loss-estimation model that was trained on the same scores fail at once. Agreement between two estimators is weaker evidence than it looks when they share an assumption.
- Estimator trust that never updates. If you only evaluate trust at deployment time, a once-good estimator will keep paging after its assumptions break. Recompute trust every time a cohort matures.
- Moving maturity windows. If you shorten the maturity window to get results faster, matured metrics become biased toward cases that resolve quickly. Version the window with each report so that reconciliation compares like with like.
- Selection in labels. If only flagged cases get investigated and labeled, matured metrics are computed on a biased sample. Reconcile against randomly sampled labels where possible, as covered in the chapter on spending a labeling budget.
What to log
For every cohort and every alert decision, store at least: the cohort id and time range, the maturity window, the estimate and interval, the estimator version, the drift flags, the decision, the later matured metric and coverage, and the error between estimate and matured metric. With this table you can answer the questions that come after an incident: did the estimator see it coming, how late would we have been without it, and how many alerts were false alarms.
Exercise
A cohort's estimate is 0.83 with a half-width of 0.01 against a floor of 0.85, and drift fired. The estimator has only three matured cohorts of history, and estimator_trusted requires four. What does decide return, and why? What changes if a fourth matured cohort with small errors is added?
Show answer
It returns "notify: estimate may be below floor (trusted=False)". With three matured cohorts the estimator is untrusted, so the confident-breach branch (trusted and upper bound 0.84 below 0.85) is skipped. The lower bound 0.82 is below the floor, so it reaches the notify branch. After a fourth cohort with small errors, the estimator becomes trusted, and the same inputs return "page: estimate confidently below floor", because the upper bound 0.84 is below 0.85.
Exercise
Why should the policy store the estimate published at the time rather than recompute it when the cohort matures?
Show answer
Reconciliation measures how good the estimate was when it was used to make a decision. A recomputed estimate would use later data and a possibly newer estimator, so the error would no longer describe the alerting system that actually ran. It would also hide estimator bias, which is the evidence you need to downgrade trust.