Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

break_down

Model Agnostic Sequential Variable Attributions


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

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

Explanatory Model Analysis. Explore, Explain and Examine Predictive Models. https://ema.drwhy.ai

See Also

Examples

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

## Not run: 
## 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])

bd_rf <- break_down(explainer_rf,
                           new_observation)
head(bd_rf)
plot(bd_rf)

## End(Not run)

iBreakDown

Model Agnostic Instance Level Variable Attributions

v2.0.1
GPL-3
Authors
Przemyslaw Biecek [aut, cre] (<https://orcid.org/0000-0001-8423-1823>), Alicja Gosiewska [aut] (<https://orcid.org/0000-0001-6563-5742>), Hubert Baniecki [aut] (<https://orcid.org/0000-0001-6661-5364>), Adam Izdebski [aut], Dariusz Komosinski [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.