Learn R Programming

DALEXtra (version 1.3.2)

plot.aspect_importance: Function for plotting aspect_importance results

Description

This function plots the results of aspect_importance.

Usage

# S3 method for aspect_importance
plot(
  x,
  ...,
  bar_width = 10,
  aspects_on_axis = TRUE,
  add_importance = FALSE,
  digits_to_round = 2,
  text_size = 3
)

Arguments

x

object of aspect_importance class

...

other parameters

bar_width

bar width

aspects_on_axis

if TRUE, labels on axis Y show aspect names, oherwise they show features names

add_importance

if TRUE, plot is annotated with values of aspects importance

digits_to_round

integer indicating the number of decimal places used for rounding values of aspects importance shown on the plot

text_size

size of labels annotating values of aspects importance, if applicable

Value

a ggplot2 object

Examples

Run this code
# NOT RUN {
library("DALEX")

model_titanic_glm <- glm(survived == 1 ~
                         class+gender+age+sibsp+parch+fare+embarked,
                         data = titanic_imputed,
                         family = "binomial")

explain_titanic_glm <- explain(model_titanic_glm,
                               data = titanic_imputed[,-8],
                               y = titanic_imputed$survived == 1,
                               verbose = FALSE)

aspects <- list(wealth = c("class", "fare"),
                family = c("sibsp", "parch"),
                personal = c("gender", "age"),
                embarked = "embarked")

plot(aspect_importance(explain_titanic_glm,
                  new_observation = titanic_imputed[1,],
                  aspects = aspects))

# }

Run the code above in your browser using DataLab