sksurv.metrics.integrated_brier_score#

sksurv.metrics.integrated_brier_score(survival_train, survival_test, estimate, times)[source]#

Computes the integrated Brier score (IBS).

The IBS is an overall measure of the model’s performance across all available time points \(t_1 \leq t \leq t_\text{max}\). It is the average Brier score, integrated over time. A lower IBS indicates better model performance.

The integrated time-dependent Brier score over the interval \([t_1; t_\text{max}]\) is defined as

\[\mathrm{IBS} = \int_{t_1}^{t_\text{max}} \mathrm{BS}^c(t) d w(t)\]

where the weighting function is \(w(t) = t / t_\text{max}\). The integral is estimated via the trapezoidal rule.

See the User Guide and [1] for further details.

Parameters:
  • survival_train (structured array, shape = (n_train_samples,)) – Survival times for the training data, used to estimate the censoring distribution. A structured array with two fields. The first field is a boolean where True indicates an event and False indicates right-censoring. The second field is a float with the time of event or time of censoring.

  • survival_test (structured array, shape = (n_samples,)) – Survival times for the test data. A structured array with two fields. The first field is a boolean where True indicates an event and False indicates right-censoring. The second field is a float with the time of event or time of censoring.

  • estimate (array-like, shape = (n_samples, n_times)) – Predicted survival probabilities for the test data at the time points specified by times, typically obtained from estimator.predict_survival_function(X). The value of estimate[:, i] must correspond to the estimated survival probability up to the time point times[i].

  • times (array-like, shape = (n_times,)) – The time points at which to compute the Brier score. Values must be within the range of follow-up times in survival_test.

Returns:

ibs – The integrated Brier score.

Return type:

float

Notes

This metric expects survival probabilities, which are typically returned by estimator.predict_survival_function(X). It does not accept risk scores.

Examples

>>> import numpy as np
>>> from sksurv.datasets import load_gbsg2
>>> from sksurv.linear_model import CoxPHSurvivalAnalysis
>>> from sksurv.metrics import integrated_brier_score
>>> from sksurv.preprocessing import OneHotEncoder

Load and prepare data.

>>> X, y = load_gbsg2()
>>> X["tgrade"] = X.loc[:, "tgrade"].map(len).astype(int)
>>> Xt = OneHotEncoder().fit_transform(X)

Fit a Cox model.

>>> est = CoxPHSurvivalAnalysis(ties="efron").fit(Xt, y)

Retrieve individual survival functions and get probability of remaining event free from 1 year to 5 years (=1825 days).

>>> survs = est.predict_survival_function(Xt)
>>> times = np.arange(365, 1826)
>>> preds = np.asarray([[fn(t) for t in times] for fn in survs])

Compute the integrated Brier score from 1 to 5 years.

>>> score = integrated_brier_score(y, y, preds, times)
>>> print(round(score, 4))
0.1816

See also

brier_score

Computes the Brier score at specified time points.

as_integrated_brier_score_scorer

Wrapper class that uses integrated_brier_score() in its score method instead of the default concordance_index_censored().

References