Fixed-horizon calibration compares predicted event probabilities with observed event shares among cases whose outcome status is known at that horizon.
Calibrate resolution predictions at a fixed horizon
Freeze the prediction time and event
Suppose a model predicts the probability that a case resolves by day six using information available at creation. Store that prediction before observing later statuses. The target is resolution by day six, not eventual resolution or any terminal exit. A case that resolves on day five is a positive outcome; a case still observed open at day eight is negative at day six. Do not turn a case censored on day four into a negative: its day-six status is unknown. Competing exits require an explicit separate target policy.
Use a fully observed teaching cohort
The code below requires each case to have a resolution event by day six or to remain observed through day six. It rejects early censoring rather than silently dropping those cases. In a production cohort with early censoring, evaluate with an appropriate censor-aware method and a censoring model whose support covers the horizon. A mature cohort formed solely by older creation dates can avoid administrative early censoring, but its population and calendar period need to match the intended deployment.
Inspect probability groups and scoring
In an eight-case ledger, four predictions at or above 0.5 average near 0.71 and three of those four cases resolve by day six. Four lower predictions average near 0.28 and one of those four resolves. These small bins are only a calculation check. Report bin counts and uncertainty before reading small differences as model failure. The Brier score is the mean squared difference between predicted resolution probability and observed six-day outcome for this fully observed fixture. Lower is better on that scoring rule.
Keep discrimination separate
A model can rank high-risk cases ahead of low-risk cases while systematically predicting 0.80 when only 0.55 resolve. A concordance statistic alone will not reveal that absolute error. Compare calibration at prespecified business horizons and operationally meaningful groups, then examine score distribution drift. Recalibration should use held-out or later data; tuning and evaluating on the same cases hides optimism. Held-out scoring offers another proper-score view.
Make censoring visible in release notes
If early censoring exists, a naive complete-case plot can be biased because short follow-up may depend on case age or queue. Document the fraction censored before the horizon by group. An inverse-censoring-weighted score requires an estimated censoring distribution and adequate support; a weight is not a substitute for investigating why cases disappeared. The model-review project gates the simple path on complete horizon observation.
Implementation
def horizon_calibration(case_predictions, horizon_days):
if horizon_days <= 0 or not case_predictions:
raise ValueError("invalid horizon or empty cohort")
if len({case_id for case_id, _, _, _ in case_predictions}) != len(case_predictions):
raise ValueError("duplicate case ID")
groups = {"lower": [], "higher": []}
squared_errors = []
for case_id, resolution_probability, observed_day, resolved in case_predictions:
if not 0 <= resolution_probability <= 1 or observed_day < 0:
raise ValueError("invalid prediction or observation")
if resolved not in (0, 1):
raise ValueError("invalid event flag")
if not resolved and observed_day < horizon_days:
raise ValueError("outcome unknown at horizon")
outcome = int(bool(resolved and observed_day <= horizon_days))
group = "higher" if resolution_probability >= 0.5 else "lower"
groups[group].append((resolution_probability, outcome))
squared_errors.append((resolution_probability - outcome) ** 2)
return {name: {"count": len(values),
"predicted": sum(prob for prob, _ in values) / len(values),
"observed": sum(outcome for _, outcome in values) / len(values)}
for name, values in groups.items() if values}, (
sum(squared_errors) / len(squared_errors))
cases = [("H71", .70, 2, 1), ("H72", .80, 4, 1),
("H73", .60, 5, 1), ("H74", .75, 8, 0),
("H75", .20, 3, 1), ("H76", .30, 8, 0),
("H77", .25, 9, 1), ("H78", .35, 8, 0)]
bins, brier = horizon_calibration(cases, 6)
assert bins["higher"]["observed"] == .75
assert bins["lower"]["observed"] == .25
assert 0 <= brier <= 1Performance and operating cost
Grouping N fully observed cases is O(N) time and O(N) space here because bin records are retained; streaming totals reduce additional space to O(1) for fixed bins. Censor-aware evaluation needs extra estimation and must not be approximated by relabeling missing outcomes.
Common Mistakes
- Do not score a case censored before the horizon as a negative.
- Do not equate ranking ability with calibrated probabilities.
- Do not tune and evaluate probability bins on the same release data without saying so.
Read next
- Cox partial likelihood and hazard-ratio interpretation
- Interval-censored support resolution times
- Held-out predictive log scores for a binary rate model
- Project: review a support-resolution survival model
Continue the workflow: IPCW Brier score for censored survival predictions.
Continue the workflow: Calibrate competing-risk predictions at a fixed horizon.
