plot.break_down_uncertainty: Plot Generic for Break Down Uncertainty Objects

Description Usage Arguments Value References Examples

View source: R/plot_break_down_uncertainty.R

Description

Plot Generic for Break Down Uncertainty Objects

Usage

1
2
3
## S3 method for class 'break_down_uncertainty'
plot(x, ...,
  vcolors = DALEX::colors_breakdown_drwhy(), show_boxplots = TRUE)

Arguments

x

an explanation created with break_down_uncertainty

...

other parameters.

vcolors

named vector with colors.

show_boxplots

logical if 'TRUE' (default) boxplot will be plotted to show uncertanity of attributions

Value

a 'ggplot2' object.

References

Predictive Models: Visual Exploration, Explanation and Debugging https://pbiecek.github.io/PM_VEE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library("DALEX")
library("iBreakDown")
# Toy examples, because CRAN angels ask for them
titanic <- na.omit(titanic)
set.seed(1313)
titanic_small <- titanic[sample(1:nrow(titanic), 500), c(1,2,6,9)]
model_titanic_glm <- glm(survived == "yes" ~ gender + age + fare,
                       data = titanic_small, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
                           data = titanic_small[,-9],
                           y = titanic_small$survived == "yes")
bd_rf <- shap(explain_titanic_glm, titanic_small[1, ])
bd_rf
plot(bd_rf)


## Not run:
library("randomForest")
set.seed(1313)

model <- randomForest(status ~ . , data = HR)
new_observation <- HR_test[1,]

explainer_rf <- explain(model,
                        data = HR[1:1000,1:5],
                        y = HR$status[1:1000])

bd_rf <- break_down_uncertainty(explainer_rf,
                           new_observation,
                           path = c(3,2,4,1,5))
bd_rf
plot(bd_rf)

# example for regression - apartment prices
# here we do not have intreactions
model <- randomForest(m2.price ~ . , data = apartments)
explainer_rf <- explain(model,
                        data = apartments_test[1:1000,2:6],
                        y = apartments_test$m2.price[1:1000])

bd_rf <- break_down_uncertainty(explainer_rf,
                                     apartments_test[1,],
                                     path = c("floor", "no.rooms", "district",
                                         "construction.year", "surface"))
bd_rf
plot(bd_rf)

bd_rf <- shap(explainer_rf,
              apartments_test[1,])
bd_rf
plot(bd_rf)
plot(bd_rf, show_boxplots = FALSE)

DrWhy2/breakDown2 documentation built on Jan. 25, 2020, 11:54 p.m.