hazardous.metrics.aj_calibration_per_event#

hazardous.metrics.aj_calibration_per_event(y_calibration, times, pred_calibration, event_of_interest=None, alpha=2, min_prop_at_risk=0.05)#

AJ calibration score per event, integrated over time.

Integrates the squared (or \(\alpha\)-th power) pointwise calibration error over time for each event:

\[\text{AJ-Cal}_k = \frac{1}{t_{\max}} \int_0^{t_{\max}} AJ_k(t)^\alpha \, dt\]

where \(AJ_k(t) = |\bar{F}_k(t) - \hat{F}^{AJ}_k(t)|\) is computed by aj_calibration_at_t(). Here \(\bar{F}_k(t) = \frac{1}{n} \sum_{i=1}^n \hat{F}_k(t \mid \mathbf{x}_i)\) is the mean predicted cumulative incidence for event \(k\) across the calibration set, \(\hat{F}^{AJ}_k(t)\) is the marginal Aalen-Johansen CIF fitted on the same set, and the survival probability (event 0) is compared against the Kaplan-Meier estimate via km_calibration().

A score of zero indicates perfect marginal calibration for event \(k\).

Parameters:
y_calibrationarray-like of shape (n_samples, 2)

Survival outcomes of the calibration set, with columns "event" and "duration".

timesarray-like of shape (n_times,)

Time points at which the CIFs were predicted.

pred_calibrationarray-like of shape (n_samples, n_events+1, n_times)

Predicted incidence probabilities at times for the calibration set.

event_of_interestint or None, default=None

If provided, return only the score for that event. If None, return a dict with one score per event.

alphaint, default=2

Exponent applied to \(AJ_k(t)\) before integration. alpha=2 gives a squared L2 calibration score; alpha=1 gives the L1 score.

min_prop_at_riskfloat, default=0.05

Lower bound on the proportion of the set still at risk required to include a timepoint in the integral. The integration stops once fewer than this fraction of subjects remain at risk, which avoids measuring noise in the tail of the time grid where the Aalen-Johansen reference is unreliable. Set to 0 to integrate over the full time grid.

Returns:
scoresdict of {int: float} or float

Integrated calibration score for each event. Returns a single float when event_of_interest is set.

See also

aj_calibration_at_t

Pointwise differences used in the integration.

aj_calibration

Aggregate all per-event scores into one number.

References

[Alberge2026]

J. Alberge, T. Haugomat, G.Varoquaux,J. Abecassis, “On the calibration of survival models with competing risks”, AISTATS 2026. <https://arxiv.org/pdf/2602.00194>