model_profile {survex} | R Documentation |
Dataset Level Variable Profile as Partial Dependence Explanations for Survival Models
Description
This function calculates explanations on a dataset level that help explore model response as a function of selected variables. The explanations are calculated as an extension of Partial Dependence Profiles with the inclusion of the time dimension.
Usage
model_profile(
explainer,
variables = NULL,
N = 100,
...,
groups = NULL,
k = NULL,
type = "partial",
center = FALSE,
output_type = "survival"
)
## S3 method for class 'surv_explainer'
model_profile(
explainer,
variables = NULL,
N = 100,
...,
categorical_variables = NULL,
grid_points = 51,
variable_splits_type = "uniform",
groups = NULL,
k = NULL,
center = FALSE,
type = "partial",
output_type = "survival"
)
Arguments
explainer |
an explainer object - model preprocessed by the |
variables |
character, a vector of names of variables to be explained |
N |
number of observations used for the calculation of aggregated profiles. By default |
... |
other parameters passed to |
groups |
if |
k |
passed to |
type |
the type of variable profile, |
center |
logical, should profiles be centered around the average prediction |
output_type |
either |
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 |
variable_splits_type |
character, decides how variable grids should be calculated. Use |
Value
An object of class model_profile_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)
rsf_src <- randomForestSRC::rfsrc(Surv(time, status) ~ ., data = veteran)
cph_exp <- explain(cph)
rsf_src_exp <- explain(rsf_src)
cph_model_profile <- model_profile(cph_exp,
output_type = "survival",
variables = c("age")
)
head(cph_model_profile$result)
plot(cph_model_profile)
rsf_model_profile <- model_profile(rsf_src_exp,
output_type = "survival",
variables = c("age", "celltype"),
type = "accumulated"
)
head(rsf_model_profile$result)
plot(rsf_model_profile, variables = c("age", "celltype"), numerical_plot_type = "contours")