Learn R Programming

DALEX (version 2.4.3)

plot.shap_aggregated: Plot Generic for Break Down Objects

Description

Displays a waterfall aggregated shap plot for objects of shap_aggregated class.

Usage

# S3 method for shap_aggregated
plot(
  x,
  ...,
  shift_contributions = 0.05,
  add_contributions = TRUE,
  add_boxplots = TRUE,
  max_features = 10,
  title = "Aggregated SHAP"
)

Value

a ggplot2 object.

Arguments

x

an explanation object created with function explain.

...

other parameters like vcolors, vnames, min_max, digits, rounding_function, baseline, subtitle, baseline, max_vars.

shift_contributions

number describing how much labels should be shifted to the right, as a fraction of range. By default equal to 0.05.

add_contributions

if TRUE, variable contributions will be added to the plot

add_boxplots

if TRUE, boxplots of SHAP will be shown

max_features

maximal number of features to be included in the plot. default value is 10.

title

a character. Plot title. By default "Break Down profile".

Examples

Run this code
library("DALEX")
set.seed(1313)
model_titanic_glm <- glm(survived ~ gender + age + fare,
                       data = titanic_imputed, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
                           data = titanic_imputed,
                           y = titanic_imputed$survived,
                           label = "glm")

# \donttest{
bd_glm <- shap_aggregated(explain_titanic_glm, titanic_imputed[1:10, ])
bd_glm
plot(bd_glm)
plot(bd_glm, max_features = 3)
plot(bd_glm, max_features = 3,
     vnames = c("average","+ male","+ young","+ cheap ticket", "+ other factors", "final"))
# }

Run the code above in your browser using DataLab