break_down: Model Agnostic Sequential Variable Attributions

Description Usage Arguments Value References See Also Examples

View source: R/break_down.R

Description

This function finds Variable Attributions via Sequential Variable Conditioning. It calls either local_attributions for additive attributions or local_interactions for attributions with interactions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
break_down(x, ..., interactions = FALSE)

## S3 method for class 'explainer'
break_down(x, new_observation, ...,
  interactions = FALSE)

## Default S3 method:
break_down(x, data, predict_function = predict,
  new_observation, keep_distributions = FALSE, order = NULL,
  label = class(x)[1], ..., interactions = FALSE)

Arguments

x

an explainer created with function explain or a model.

...

parameters passed to 'local_*' functions.

interactions

shall interactions be included?

new_observation

a new observation with columns that correspond to variables used in the model.

data

validation dataset, will be extracted from 'x' if it is an explainer.

predict_function

predict function, will be extracted from ‘x' if it’s an explainer.

keep_distributions

if 'TRUE', then distribution of partial predictions is stored and can be plotted with the generic 'plot()'.

order

if not 'NULL', then it will be a fixed order of variables. It can be a numeric vector or vector with names of variables.

label

name of the model. By default it is extracted from the 'class' attribute of the model.

Value

an object of the 'break_down' class.

References

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

See Also

local_attributions, local_interactions

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
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 <- break_down(explain_titanic_glm, titanic_small[1, ])
bd_rf
plot(bd_rf, max_features = 3)


## Not run:
library("randomForest")
set.seed(1313)
# example with interaction
# classification for HR data
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(explainer_rf,
                           new_observation)
bd_rf
plot(bd_rf)

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