plotD3_break_down: Plot Break Down Objects in D3 with r2d3 package.

Description Usage Arguments Value References Examples

Description

Plots waterfall break down for objects of the break_down class.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
plotD3(x, ...)

## S3 method for class 'break_down'
plotD3(
  x,
  ...,
  baseline = NA,
  max_features = 10,
  digits = 3,
  rounding_function = round,
  bar_width = 12,
  margin = 0.2,
  scale_height = FALSE,
  min_max = NA,
  vcolors = NA,
  chart_title = NA,
  time = 0,
  max_vars = NULL
)

Arguments

x

an explanation created with break_down

...

other parameters.

baseline

if numeric then veritical line will start in baseline.

max_features

maximal number of features to be included in the plot. By default it's 10.

digits

number of decimal places (round) or significant digits (signif) to be used. See the rounding_function argument.

rounding_function

a function to be used for rounding numbers. This should be signif which keeps a specified number of significant digits or round (which is default) to have the same precision for all components.

bar_width

width of bars in px. By default it's 12px

margin

extend x axis domain range to adjust the plot. Usually value between 0.1 and 0.3, by default it's 0.2

scale_height

if TRUE, the height of the plot scales with window size

min_max

a range of OX axis. By deafult NA therefore will be extracted from the contributions of x. But can be set to some constants, usefull if these plots are used for comparisons.

vcolors

If NA (default), DrWhy colors are used.

chart_title

a character. Set custom title

time

in ms. Set the animation length

max_vars

alias for the max_features parameter.

Value

a r2d3 object.

References

Explanatory Model Analysis. Explore, Explain and Examine Predictive Models. https://pbiecek.github.io/ema

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
library("DALEX")
library("iBreakDown")
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 <- local_attributions(explain_titanic_glm, titanic_imputed[1, ])
bd_glm
plotD3(bd_glm)

## Not run: 
## Not run:
library("randomForest")

m_rf <- randomForest(status ~ . , data = HR[2:2000,])
new_observation <- HR_test[1,]
new_observation

p_fun <- function(object, newdata){predict(object, newdata=newdata, type = "prob")}

bd_rf <- local_attributions(m_rf,
                           data = HR_test,
                           new_observation =  new_observation,
                           predict_function = p_fun)

bd_rf
plotD3(bd_rf)

## End(Not run)

pbiecek/breakDown2 documentation built on Aug. 8, 2020, 2:53 p.m.