Ceteris Paribus Plot

ceteris_paribus(explainer, observation, grid_points = 101,
  selected_variables = NULL)

Arguments

explainer

a model to be explained, preprocessed by the 'DALEX::explain' function

observation

a new observarvation for which predictions need to be explained

grid_points

number of points used for response path

selected_variables

if specified, then only these variables will be explained

Value

An object of the class 'ceteris_paribus_explainer'. It's a data frame with calculated average responses.

Examples

library("DALEX") library("randomForest") set.seed(59) apartments_rf_model <- randomForest(m2.price ~ construction.year + surface + floor + no.rooms + district, data = apartments) explainer_rf <- explain(apartments_rf_model, data = apartmentsTest[,2:6], y = apartmentsTest$m2.price) new_apartment <- apartmentsTest[1, ] new_apartment
#> m2.price construction.year surface floor no.rooms district #> 1001 4644 1976 131 3 5 Srodmiescie
wi_rf <- ceteris_paribus(explainer_rf, observation = new_apartment) wi_rf
#> y_hat new_x vname x_quant quant relative_quant label #> 0% 4255.354 1920 construction.year 0.6268889 0.00 -0.6268889 randomForest #> 1% 4300.702 1921 construction.year 0.6268889 0.01 -0.6168889 randomForest #> 2% 4301.926 1922 construction.year 0.6268889 0.02 -0.6068889 randomForest #> 3% 4305.352 1923 construction.year 0.6268889 0.03 -0.5968889 randomForest #> 4% 4305.352 1923 construction.year 0.6268889 0.04 -0.5868889 randomForest #> 5% 4267.723 1924 construction.year 0.6268889 0.05 -0.5768889 randomForest
wi_rf <- ceteris_paribus(explainer_rf, observation = new_apartment, selected_variables = c("surface", "floor", "no.rooms")) wi_rf
#> y_hat new_x vname x_quant quant relative_quant label #> 0% 4768.305 20 surface 0.8541111 0.00 -0.8541111 randomForest #> 1% 4765.291 21 surface 0.8541111 0.01 -0.8441111 randomForest #> 2% 4761.576 23 surface 0.8541111 0.02 -0.8341111 randomForest #> 3% 4760.838 24 surface 0.8541111 0.03 -0.8241111 randomForest #> 4% 4760.290 26 surface 0.8541111 0.04 -0.8141111 randomForest #> 5% 4743.734 27 surface 0.8541111 0.05 -0.8041111 randomForest