plot.aspect_importance: Function for plotting aspect_importance results

Description Usage Arguments Value Examples

View source: R/aspect_importance.R

Description

This function plots the results of aspect_importance.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'aspect_importance'
plot(
  x,
  ...,
  bar_width = 10,
  show_features = aspects_on_axis,
  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

show_features

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

aspects_on_axis

alias for show_features held for backwards compatibility

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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")

titanic_ai <- predict_aspects(explain_titanic_glm,
                  new_observation = titanic_imputed[1,],
                  variable_groups = aspects)
plot(titanic_ai)

triplot documentation built on July 13, 2020, 5:08 p.m.