model_profile_2d {survex} | R Documentation |
Dataset Level 2-Dimensional Variable Profile for Survival Models
Description
This function calculates explanations on a dataset level that help explore model response as a function of selected pairs of variables. The explanations are calculated as an extension of Partial Dependence Profiles or Accumulated Local Effects with the inclusion of the time dimension.
Usage
model_profile_2d(
explainer,
variables = NULL,
N = 100,
categorical_variables = NULL,
grid_points = 25,
center = FALSE,
variable_splits_type = "uniform",
type = "partial",
output_type = "survival"
)
## S3 method for class 'surv_explainer'
model_profile_2d(
explainer,
variables = NULL,
N = 100,
categorical_variables = NULL,
grid_points = 25,
center = FALSE,
variable_splits_type = "uniform",
type = "partial",
output_type = "survival"
)
Arguments
explainer |
an explainer object - model preprocessed by the |
variables |
list of character vectors of length 2, names of pairs of variables to be explained |
N |
number of observations used for the calculation of aggregated profiles. By default |
categorical_variables |
character, a vector of names of additional variables which should be treated as categorical (factors are automatically treated as categorical variables). If it contains variable names not present in the |
grid_points |
maximum number of points for profile calculations. Note that the final number of points may be lower than grid_points. Will be passed to internal function. By default |
center |
logical, should profiles be centered around the average prediction |
variable_splits_type |
character, decides how variable grids should be calculated. Use |
type |
the type of variable profile, |
output_type |
either |
Value
An object of class model_profile_2d_survival
. It is a list with the element result
containing the results of the calculation.
Examples
library(survival)
library(survex)
cph <- coxph(Surv(time, status) ~ ., data = veteran, model = TRUE, x = TRUE, y = TRUE)
cph_exp <- explain(cph)
cph_model_profile_2d <- model_profile_2d(cph_exp,
variables = list(c("age", "celltype"))
)
head(cph_model_profile_2d$result)
plot(cph_model_profile_2d)
cph_model_profile_2d_ale <- model_profile_2d(cph_exp,
variables = list(c("age", "karno")),
type = "accumulated"
)
head(cph_model_profile_2d_ale$result)
plot(cph_model_profile_2d_ale)