Instance Level Variable Attributions as Break Down, SHAP or Oscillations explanations.
Model prediction is decomposed into parts that are attributed for particular variables.
From DALEX version 1.0 this function calls the break_down
or
shap
functions from the iBreakDown
package or
ceteris_paribus
from the ingredients
package.
Find information how to use the break_down
method here: http://ema.drwhy.ai/breakDown.html.
Find information how to use the shap
method here: http://ema.drwhy.ai/shapley.html.
Find information how to use the oscillations
method here: http://ema.drwhy.ai/ceterisParibusOscillations.html.
predict_parts(
explainer,
new_observation,
...,
N = if (substr(type, 1, 4) == "osci") 500 else NULL,
type = "break_down"
)predict_parts_oscillations(explainer, new_observation, ...)
predict_parts_oscillations_uni(
explainer,
new_observation,
variable_splits_type = "uniform",
...
)
predict_parts_oscillations_emp(
explainer,
new_observation,
variable_splits = NULL,
variables = colnames(explainer$data),
...
)
predict_parts_break_down(explainer, new_observation, ...)
predict_parts_break_down_interactions(explainer, new_observation, ...)
predict_parts_shap(explainer, new_observation, ...)
variable_attribution(
explainer,
new_observation,
...,
N = if (substr(type, 1, 4) == "osci") 500 else NULL,
type = "break_down"
)
a model to be explained, preprocessed by the explain
function
a new observation for which predictions need to be explained
other parameters that will be passed to iBreakDown::break_down
the maximum number of observations used for calculation of attributions. By default NULL (use all) or 500 (for oscillations).
the type of variable attributions. Either shap
, oscillations
, oscillations_uni
,
oscillations_emp
, break_down
or break_down_interactions
.
how variable grids shall be calculated? Will be passed to ceteris_paribus
.
named list of splits for variables. It is used by oscillations based measures. Will be passed to ceteris_paribus
.
names of variables for which splits shall be calculated. Will be passed to ceteris_paribus
.
Depending on the type
there are different classes of the resulting object.
It's a data frame with calculated average response.
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. http://ema.drwhy.ai/
# NOT RUN { library(DALEX) new_dragon <- data.frame( year_of_birth = 200, height = 80, weight = 12.5, scars = 0, number_of_lost_teeth = 5 ) model_lm <- lm(life_length ~ year_of_birth + height + weight + scars + number_of_lost_teeth, data = dragons) explainer_lm <- explain(model_lm, data = dragons, y = dragons$year_of_birth, label = "model_lm") bd_lm <- predict_parts_break_down(explainer_lm, new_observation = new_dragon) head(bd_lm) plot(bd_lm) # } # NOT RUN { library("ranger") model_ranger <- ranger(life_length ~ year_of_birth + height + weight + scars + number_of_lost_teeth, data = dragons, num.trees = 50) explainer_ranger <- explain(model_ranger, data = dragons, y = dragons$year_of_birth, label = "model_ranger") bd_ranger <- predict_parts_break_down(explainer_ranger, new_observation = new_dragon) head(bd_ranger) plot(bd_ranger) # } # NOT RUN { # }