ceteris_paribus_2d: Ceteris Paribus 2D Plot In ingredients: Effects and Importances of Model Ingredients

Description

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.

Usage

 1 ceteris_paribus_2d(explainer, observation, grid_points = 101, variables = NULL)

Arguments

 explainer a model to be explained, preprocessed by the DALEX::explain() function 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

Value

an object of the class ceteris_paribus_2d_explainer.

References

Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/

Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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)

ingredients documentation built on April 10, 2021, 5:06 p.m.