Sub topic 3
Choosing a label maturity window
This chapter assumes you can compute accuracy, precision, recall and ROC AUC, and that you are comfortable with pandas and scikit-learn. It also assumes you know what a prediction log is. The previous chapters explained why labels arrive late and what that does to monitoring. Here you decide how long to wait before a label counts as "final".
What a maturity window is
A label maturity window is the minimum age a prediction must reach before you score it. A prediction is mature when enough time has passed that its true label has almost certainly arrived. Predictions younger than the window are immature. Their labels may be missing because the outcome has not happened yet, not because the outcome is negative.
The window is a trade-off between two errors:
- A window that is too short scores predictions whose positives have not shown up yet. Metrics look better or worse than the truth, depending on the metric.
- A window that is too long makes the metric accurate but stale. You learn about a problem weeks after it started.
You cannot remove this trade-off. You can only pick a point on it deliberately and report it.
Why a short window distorts metrics
Suppose a fraud model scores card transactions. Chargebacks arrive up to 60 days after the purchase. If you score transactions that are only 5 days old, most true fraud cases have no chargeback yet. They look like negatives.
Treating missing labels as negatives has predictable effects:
- Recall falls, because real positives are counted as negatives, so the model appears to miss fraud it actually caught.
- Precision falls, because high-scoring cases that are really fraud are counted as false positives.
- ROC AUC drifts toward 0.5, because the late-arriving positives that the model ranked highly are labeled 0.
- The measured positive rate is lower than the real one.
The error is not random. It depends on the age of the data, so a metric computed on a mix of old and young predictions changes as the mix changes, even if the model has not changed.
Measure the delay distribution
Choose the window from data, not from a guess. For every positive label you have received, compute the lag between the prediction time and the time the label arrived. Then look at the distribution of that lag.
The label arrival curve is the cumulative share of eventual labels that have arrived after each age. If 90% of positives arrive within 30 days, a 30-day window leaves about 10% of positives missing.
The code below computes the curve from a table of labeled positives. It then reports the smallest age at which a chosen share of labels has arrived.
import numpy as np
import pandas as pd
def label_lag_days(positives: pd.DataFrame) -> pd.Series:
"""Lag in days between prediction and label arrival.
positives: columns predicted_at, label_received_at (both datetimes),
one row per positive outcome.
"""
lag = positives["label_received_at"] - positives["predicted_at"]
return lag.dt.total_seconds() / 86400.0
def window_for_coverage(lag_days: pd.Series, target: float = 0.95) -> float:
"""Smallest age (days) by which `target` of positive labels have arrived."""
return float(np.quantile(lag_days.dropna(), target))
positives = pd.DataFrame({
"predicted_at": pd.to_datetime(
["2026-01-01", "2026-01-01", "2026-01-02", "2026-01-03", "2026-01-03"]
),
"label_received_at": pd.to_datetime(
["2026-01-04", "2026-01-12", "2026-01-09", "2026-01-30", "2026-02-20"]
),
})
lags = label_lag_days(positives)
print(lags.round(1).tolist())
print("90% window (days):", round(window_for_coverage(lags, 0.90), 1))
print("95% window (days):", round(window_for_coverage(lags, 0.95), 1))Treat a small sample like the one above as an illustration only. In practice, use thousands of positives so the tail of the distribution is estimated reliably.
A caveat: the curve is itself censored
You can only observe lags that are shorter than the age of your oldest data. If your log covers 90 days and some labels take 120 days, those labels have not arrived and do not appear in the curve. The curve then looks like it reaches 100% earlier than it really does. Check the delay against a business source, such as the chargeback policy or the contract term, and do not rely on the observed tail alone.
Also compute the curve only from predictions old enough to be fully observed. Otherwise young predictions pull the curve toward short lags.
Choosing the target coverage
Pick a coverage target, such as 90%, 95% or 99%, and read the window off the arrival curve. Consider these factors:
| Factor | Pushes the window | Reason |
|---|---|---|
| Cost of a missed degradation | Shorter | Fast detection matters more than exact numbers. |
| Cost of a false alarm | Longer | Biased metrics trigger needless investigations. |
| Heavy tail in label delay | Longer, or use two windows | The last 5% may take as long as the first 95%. |
| Rare positives | Longer | Few positives make every missing one a large relative error. |
| Label delay differs by segment | Per-segment windows | One global window is wrong for the slow segment. |
A practical pattern is to run two evaluations:
- A fast window at about 80–90% coverage. It gives an early but slightly biased signal. Use it for trend and alerting.
- A final window at 99% or at the contractual limit. It gives the number you report and use to judge past estimates.
Both numbers should be labeled with their window in dashboards. A metric without its window is hard to interpret.
Scoring only mature predictions
The matured-cohort function below applies the window. It scores predictions at or beyond the cutoff and returns the share of predictions that qualified, so readers see how stale the metric is.
import pandas as pd
from sklearn.metrics import roc_auc_score
def matured_auc(preds: pd.DataFrame, labels: pd.DataFrame,
now: pd.Timestamp, maturity: pd.Timedelta):
"""AUC on predictions old enough that their label should have arrived.
preds: columns id, predicted_at, score
labels: columns id, label (only rows whose outcome is known)
"""
cutoff = now - maturity
mature = preds[preds["predicted_at"] <= cutoff]
joined = mature.merge(labels[["id", "label"]], on="id", how="left")
# Assumption: after the maturity window, a missing label means "negative"
# (for example, no chargeback was filed). Check this for your domain.
joined["label"] = joined["label"].fillna(0).astype(int)
coverage = len(mature) / len(preds) if len(preds) else 0.0
return roc_auc_score(joined["label"], joined["score"]), coverageTwo details matter here.
- The
fillna(0)line is only valid after the window has passed. It encodes the claim "no label by now means negative". If that claim is false for your domain, for example because labels need a manual review that is backlogged, the metric is biased. - The returned
coverageis the share of logged predictions that are old enough. If it is 0.4, the metric describes only the oldest 40% of your traffic. Always show it next to the metric.
Windows that depend on the metric
Different metrics tolerate immature labels differently.
- Recall and AUC are sensitive to missing positives, so they need a long window.
- Precision is also affected, because late positives are counted as false positives among the flagged cases.
- Calibration error and log loss are affected, because the observed positive rate is too low.
- Score distributions and drift statistics need no labels, so they have no window at all.
If the model flags only a small review queue, you may be able to obtain labels for the flagged cases quickly, because they are reviewed. Those labels are not representative of the unflagged traffic. That selection effect is covered in the chapter on censoring and selection bias.
Edge cases
- Labels that can flip. A label may arrive as negative and later change to positive, for example a loan that defaults after months of payments. A window then has to cover the longest realistic flip time, or you must label the outcome as "default within N months" and define N as part of the target.
- Right-censored outcomes. If the target is "churn within 90 days", a prediction is mature only after 90 days, regardless of how fast most labels arrive. The definition of the target sets a minimum window.
- Seasonality in delay. Delay can lengthen at the end of the quarter or during holidays when review teams are slow. Recompute the arrival curve regularly and compare it with earlier ones.
- Changing delay. A process change, such as a faster review team, shifts the curve. A window chosen last year may now be too long. Monitor the lag distribution itself as a metric.
- Per-cohort differences. Reporting one window for all customers hides that one product line may need twice as long as another.
A worked decision
Suppose a credit model's positives arrive with these lags: 50% within 30 days, 90% within 90 days, 98% within 180 days. Management wants to know about degradation within a quarter.
- Final window: 180 days, which gives 98% coverage. Use it to evaluate past estimates and to report official numbers.
- Fast window: 90 days, which gives 90% coverage. Use it for monitoring, knowing that recall is understated by up to ten percentage points of the positives.
- For anything younger than 90 days, rely on label-free estimates, which later chapters cover.
The fast window leaves the most recent three months without a ground-truth metric. That gap is the reason the rest of this tutorial exists.
Exercise
A fraud model's chargebacks arrive with a 95th-percentile delay of 45 days. Your log covers 60 days. A teammate scores all predictions older than 7 days and treats missing labels as negative. Name two problems with this choice and propose a better setup.
Show answer
First, a 7-day window captures only a small share of eventual chargebacks, so many true frauds are labeled negative, which lowers recall and moves AUC toward 0.5, and the number changes with the age mix of the data. Second, the delay curve is itself censored by a 60-day log, so the observed tail may understate real delays; confirm the maximum delay from the chargeback policy. A better setup is a fast window near the 80–90% coverage point for trend monitoring and a final window of about 45 days or more (matching the policy limit) for reported numbers, with the coverage of qualifying predictions shown beside each metric.
Exercise
Your matured_auc function returns an AUC of 0.88 and a coverage of 0.35. What does the coverage tell you, and what should you do before reporting the AUC?
Show answer
Only 35% of logged predictions are old enough to be scored, so the AUC describes the oldest third of traffic and says nothing about recent behavior. Report the coverage and window next to the AUC, and use label-free signals or estimates for the newer 65% before drawing conclusions about current performance.