Skip to contents

Bridges a fitted SuperSurv ensemble or a single base learner to the survex package for Time-Dependent SHAP and Model Parts.

Usage

explain_survex(model, data, y, times, label = NULL)

Arguments

model

A fitted SuperSurv object OR a single wrapper output.

data

Covariate data for explanation (data.frame).

y

The survival object (Surv(time, event)).

times

The time grid for evaluation.

label

Optional character string to name the explainer.

Value

An explainer object of class survex_explainer created by explain_survival, which can be passed to DALEX and survex functions for further model diagnostics and plotting.

Examples

if (requireNamespace("survex", quietly = TRUE) &&
    requireNamespace("glmnet", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:80, ]
  x_cols <- grep("^x", names(dat))[1:5]
  X <- dat[, x_cols, drop = FALSE]
  times <- seq(20, 120, by = 20)
  y <- survival::Surv(dat$duration, dat$event)

  fit <- SuperSurv(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = X,
    new.times = times,
    event.library = c("surv.coxph", "surv.ridge"),
    cens.library = c("surv.coxph"),
    control = list(saveFitLibrary = TRUE)
  )

  explainer <- explain_survex(
    model = fit,
    data = X,
    y = y,
    times = times,
    label = "SuperSurv_demo"
  )

  class(explainer)
}
#> [1] "surv_explainer" "explainer"