partial_dependence {ingredients} | R Documentation |
Partial Dependence Profiles
Description
Partial Dependence Profiles are averages from Ceteris Paribus Profiles.
Function partial_dependence
calls ceteris_paribus
and then aggregate_profiles
.
Usage
partial_dependence(x, ...)
## S3 method for class 'explainer'
partial_dependence(
x,
variables = NULL,
N = 500,
variable_splits = NULL,
grid_points = 101,
...,
variable_type = "numerical"
)
## Default S3 method:
partial_dependence(
x,
data,
predict_function = predict,
label = class(x)[1],
variables = NULL,
grid_points = 101,
variable_splits = NULL,
N = 500,
...,
variable_type = "numerical"
)
## S3 method for class 'ceteris_paribus_explainer'
partial_dependence(x, ..., variables = NULL)
partial_dependency(x, ...)
Arguments
x |
an explainer created with function |
... |
other parameters |
variables |
names of variables for which profiles shall be calculated.
Will be passed to |
N |
number of observations used for calculation of partial dependence profiles. By default |
variable_splits |
named list of splits for variables, in most cases created with |
grid_points |
number of points for profile. Will be passed to |
variable_type |
a character. If |
data |
validation dataset, will be extracted from |
predict_function |
predict function, will be extracted from |
label |
name of the model. By default it's extracted from the |
Details
Find more details in the Partial Dependence Profiles Chapter.
Value
an object of the class aggregated_profiles_explainer
References
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/
Examples
library("DALEX")
model_titanic_glm <- glm(survived ~ gender + age + fare,
data = titanic_imputed, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
data = titanic_imputed[,-8],
y = titanic_imputed[,8],
verbose = FALSE)
pdp_glm <- partial_dependence(explain_titanic_glm,
N = 25, variables = c("age", "fare"))
head(pdp_glm)
plot(pdp_glm)
library("ranger")
model_titanic_rf <- ranger(survived ~., data = titanic_imputed, probability = TRUE)
explain_titanic_rf <- explain(model_titanic_rf,
data = titanic_imputed[,-8],
y = titanic_imputed[,8],
label = "ranger forest",
verbose = FALSE)
pdp_rf <- partial_dependence(explain_titanic_rf, variable_type = "numerical")
plot(pdp_rf)
pdp_rf <- partial_dependence(explain_titanic_rf, variable_type = "categorical")
plotD3(pdp_rf, label_margin = 80, scale_plot = TRUE)