sksurv.metrics.brier_score¶

sksurv.metrics.
brier_score
(survival_train, survival_test, estimate, times)[source]¶ Estimate the timedependent Brier score for right censored data.
The timedependent Brier score is the mean squared error at time point \(t\):
\[\mathrm{BS}^c(t) = \frac{1}{n} \sum_{i=1}^n I(y_i \leq t \land \delta_i = 1) \frac{(0  \hat{\pi}(t  \mathbf{x}_i))^2}{\hat{G}(y_i)} + I(y_i > t) \frac{(1  \hat{\pi}(t  \mathbf{x}_i))^2}{\hat{G}(t)} ,\]where \(\hat{\pi}(t  \mathbf{x})\) is the predicted probability of remaining eventfree up to time point \(t\) for a feature vector \(\mathbf{x}\), and \(1/\hat{G}(t)\) is a inverse probability of censoring weight, estimated by the KaplanMeier estimator.
See [1] for details.
Parameters:  survival_train (structured array, shape = (n_train_samples,)) – Survival times for training data to estimate the censoring distribution from. A structured array containing the binary event indicator as first field, and time of event or time of censoring as second field.
 survival_test (structured array, shape = (n_samples,)) – Survival times of test data. A structured array containing the binary event indicator as first field, and time of event or time of censoring as second field.
 estimate (arraylike, shape = (n_samples, n_times)) – Estimated risk of experiencing an event for test data at times. The ith column must contain the estimated probability of remaining eventfree up to the ith time point.
 times (arraylike, shape = (n_times,)) – The time points for which to estimate the Brier score. Values must be within the range of followup times of the test data survival_test.
Returns:  times (array, shape = (n_times,)) – Unique time points at which the brier scores was estimated.
 brier_scores (array , shape = (n_times,)) – Values of the brier score.
Examples
>>> from sksurv.datasets import load_gbsg2 >>> from sksurv.linear_model import CoxPHSurvivalAnalysis >>> from sksurv.metrics import brier_score >>> from sksurv.preprocessing import OneHotEncoder
Load and prepare data.
>>> X, y = load_gbsg2() >>> X.loc[:, "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 up to 5 years (=1825 days).
>>> survs = est.predict_survival_function(Xt) >>> preds = [fn(1825) for fn in survs]
Compute the Brier score at 5 years.
>>> times, score = brier_score(y, y, preds, 1825) >>> print(score) [0.20881843]
See also
References
[1] E. Graf, C. Schmoor, W. Sauerbrei, and M. Schumacher, “Assessment and comparison of prognostic classification schemes for survival data,” Statistics in Medicine, vol. 18, no. 1718, pp. 2529–2545, 1999.