Learn R Programming

ceterisParibus (version 0.4.2)

plot.what_if_explainer: Plot What If Explanations

Description

Function 'plot.what_if_explainer' plots What-If Plots for a single prediction / observation.

Usage

# S3 method for what_if_explainer
plot(
  x,
  ...,
  quantiles = TRUE,
  split = "models",
  split_ncol = NULL,
  color = "variables"
)

Value

a ggplot2 object

Arguments

x

a ceteris paribus explainer produced with the 'what_if' function

...

other explainers that shall be plotted together

quantiles

if TRUE (default) then quantiles will be presented on OX axis. If FALSE then original values will be presented on OX axis

split

a character, either 'models' or 'variables'. Sets the variable for faceting

split_ncol

number of columns for the 'facet_wrap'

color

a character, either 'models' or 'variables'. Sets the variable for coloring

Examples

Run this code
library("DALEX")
 if (FALSE) {
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

wi_rf <- what_if(explainer_rf, observation = new_apartment)
wi_rf

plot(wi_rf, split = "variables", color = "variables")
plot(wi_rf)
}

Run the code above in your browser using DataLab