Survival curves and confidence intervals (CIs) can be estimated using the Exponential Greenwood formula.
For XBGSEKaplanTree and XBGSEKaplanNeighbors
These models support CI estimation out-of-the-box using the return_ci=True argument in .predict(). Note that for XBGSEKaplanTree, the ci_width parameter must be passed during .fit(), whereas for XBGSEKaplanNeighbors, it is passed during .predict().
For XGBSEDebiasedBCE
This model does not support CIs out-of-the-box. Instead, use the XGBSEBootstrapEstimator to obtain non-parametric confidence intervals via bootstrapping.
Using XGBSEBootstrapEstimator
You can wrap any base model (including XBGSEKaplanTree or XBGSEKaplanNeighbors) with XGBSEBootstrapEstimator to get more stable, non-parametric CIs. This estimator also allows building CIs for interval probabilities, which the Exponential Greenwood formula does not support.
# Example for KaplanNeighbors with CI
# ci_width is passed at .predict()
model = XGBSEKaplanNeighbors(PARAMS_XGB_AFT, N_NEIGHBORS)
model.fit(X_train, y_train, time_bins=TIME_BINS)
mean, upper_ci, lower_ci = model.predict(X_valid, return_ci=True, ci_width=0.99)
# Example for KaplanTree with CI
# ci_width is passed at .fit()
xgbse_model = XGBSEKaplanTree(PARAMS_TREE)
xgbse_model.fit(X_train, y_train, time_bins=TIME_BINS, ci_width=0.99)
mean, upper_ci, lower_ci = xgbse_model.predict(X_valid, return_ci=True)
# Example using Bootstrap Estimator
base_model = XGBSEDebiasedBCE(PARAMS_XGB_AFT, PARAMS_LR)
bootstrap_estimator = XGBSEBootstrapEstimator(base_model, n_estimators=20)
bootstrap_estimator.fit(X_train, y_train, validation_data=(X_valid, y_valid), early_stopping_rounds=10, time_bins=TIME_BINS)
mean, upper_ci, lower_ci = bootstrap_estimator.predict(X_valid, return_ci=True)