View source: R/ceteris_paribus_2d.R
ceteris_paribus_2d | R Documentation |
This function calculates ceteris paribus profiles for grid of values spanned by two variables. It may be useful to identify or present interactions between two variables.
ceteris_paribus_2d(explainer, observation, grid_points = 101, variables = NULL)
explainer |
a model to be explained, preprocessed by the |
observation |
a new observation for which predictions need to be explained |
grid_points |
number of points used for response path. Will be used for both variables |
variables |
if specified, then only these variables will be explained |
an object of the class ceteris_paribus_2d_explainer
.
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/
library("DALEX") library("ingredients") model_titanic_glm <- glm(survived ~ age + fare, data = titanic_imputed, family = "binomial") explain_titanic_glm <- explain(model_titanic_glm, data = titanic_imputed[,-8], y = titanic_imputed[,8]) cp_rf <- ceteris_paribus_2d(explain_titanic_glm, titanic_imputed[1,], variables = c("age", "fare", "sibsp")) head(cp_rf) plot(cp_rf) library("ranger") set.seed(59) apartments_rf_model <- ranger(m2.price ~., data = apartments) explainer_rf <- explain(apartments_rf_model, data = apartments_test[,-1], y = apartments_test[,1], label = "ranger forest", verbose = FALSE) new_apartment <- apartments_test[1,] new_apartment wi_rf_2d <- ceteris_paribus_2d(explainer_rf, observation = new_apartment, variables = c("surface", "floor", "no.rooms")) head(wi_rf_2d) plot(wi_rf_2d)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.