plot.shap_aggregated: Plot Generic for Break Down Objects

View source: R/plot_shap_aggregated.R

plot.shap_aggregatedR Documentation

Plot Generic for Break Down Objects

Description

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

Usage

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

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".

Value

a ggplot2 object.

Examples

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")


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"))



DALEX documentation built on Jan. 16, 2023, 1:06 a.m.