| model_parts {survex} | R Documentation | 
Dataset Level Variable Importance for Survival Models
Description
This function calculates variable importance as a change in the loss function after the variable values permutations.
Usage
model_parts(explainer, ...)
## S3 method for class 'surv_explainer'
model_parts(
  explainer,
  loss_function = survex::loss_brier_score,
  ...,
  type = "difference",
  output_type = "survival",
  N = 1000
)
Arguments
explainer | 
 an explainer object - model preprocessed by the   | 
... | 
 Arguments passed on to  
  | 
loss_function | 
 a function that will be used to assess variable importance, by default   | 
type | 
 a character vector, if   | 
output_type | 
 either   | 
N | 
 number of observations that should be sampled for calculation of variable importance. If   | 
Details
Note: This function can be run within progressr::with_progress() to display a progress bar, as the execution can take long, especially on large datasets.
Value
An object of class c("model_parts_survival", "surv_feature_importance"). It's a list with the explanations in the result element.
Examples
library(survival)
library(survex)
cph <- coxph(Surv(time, status) ~ ., data = veteran, model = TRUE, x = TRUE, y = TRUE)
rsf_ranger <- ranger::ranger(Surv(time, status) ~ .,
  data = veteran,
  respect.unordered.factors = TRUE,
  num.trees = 100,
  mtry = 3,
  max.depth = 5
)
cph_exp <- explain(cph)
rsf_ranger_exp <- explain(rsf_ranger,
  data = veteran[, -c(3, 4)],
  y = Surv(veteran$time, veteran$status)
)
cph_model_parts_brier <- model_parts(cph_exp)
print(head(cph_model_parts_brier$result))
plot(cph_model_parts_brier)
rsf_ranger_model_parts <- model_parts(rsf_ranger_exp)
print(head(rsf_ranger_model_parts$result))
plot(cph_model_parts_brier, rsf_ranger_model_parts)