Sub topic 11
Handling Delayed and Missing Labels
Assume you can serve models behind an HTTP or RPC endpoint, read Python and YAML, and understand proportions, averages, and metrics such as precision, recall, and latency. This chapter focuses on a harder production problem: the correct label often arrives after the prediction.
A label is the outcome used to judge a prediction. For a fraud model, the label might be “confirmed fraud.” For a recommendation model, it might be “user purchased within 14 days.” A prediction cannot be scored fairly until its label is mature, meaning enough time has passed for the outcome to be observed.
Why labels are delayed
Online metrics such as latency and error rate are available immediately. Model quality metrics often are not.
A fraud prediction may receive a confirmed label weeks later. A churn prediction may need 30 days of inactivity. A ranking experiment may use a purchase label that arrives hours after a click. If you compare a candidate with the stable model before these windows close, you measure different populations of completed and incomplete outcomes.
| Label state | Meaning | Safe use |
|---|---|---|
| Mature | The observation window has closed | Score model quality |
| Pending | The outcome may still arrive | Track for completeness |
| Missing | The outcome was expected but did not arrive | Investigate or model separately |
| Not applicable | No valid outcome exists for this request | Exclude with a documented rule |
Do not treat every missing label as a negative label. A missing fraud confirmation may mean “not investigated yet,” not “legitimate.” This distinction is called missingness. Missingness is especially dangerous when it depends on the prediction, user, or treatment group.
Build a label-maturity pipeline
Log each prediction with an immutable event ID, model version, assignment group, prediction time, and the features needed for analysis. Later, join the prediction log to outcome events using that event ID. Define the maturity time before the rollout starts.
For example, if a purchase label can arrive within seven days, calculate conversion only for predictions at least seven days old. Keep a separate pending count so you can detect whether one group has more unfinished observations.
from datetime import datetime, timedelta, timezone
def mature_predictions(predictions, now, window_days):
cutoff = now - timedelta(days=window_days)
return [
prediction for prediction in predictions
if prediction["predicted_at"] <= cutoff
and prediction["label"] is not None
]
now = datetime.now(timezone.utc)
predictions = [
{
"event_id": "a1",
"group": "stable",
"predicted_at": now - timedelta(days=8),
"label": 1,
},
{
"event_id": "a2",
"group": "candidate",
"predicted_at": now - timedelta(days=2),
"label": None,
},
]
print(mature_predictions(predictions, now, window_days=7))This code filters for both a closed observation window and an available label. In a real system, validate timestamps and preserve the original records rather than overwriting them.
Missingness and rollout decisions
Compare label availability by group, model version, geography, and important user segments. A candidate that changes user behavior may also change who generates a label. For example, a new fraud model may cause more transactions to be reviewed, increasing confirmed labels for the candidate group.
Use immediate guardrails to protect the service while labels mature:
- error rate and timeout rate
- p95 or p99 latency
- request volume and assignment counts
- safety, complaint, or abuse signals
- label-arrival rate and pending-age distribution
Delay quality-based promotion until the required labels mature. If the business requires an early decision, define a conservative stopping rule in advance and report the result as provisional.
Exercise
A candidate has a 6% conversion rate after two days, while stable has 5%. The purchase label normally takes seven days to mature. Can you promote the candidate based on this result?
Show answer
No. The comparison is provisional because recent candidate predictions have incomplete outcomes. Wait for the seven-day window, compare mature cohorts, and monitor immediate service guardrails meanwhile.