Learn R Programming

DALEX (version 1.2.1)

predict_parts: Instance Level Parts of the Model Predictions

Description

Instance Level Variable Attributions as Break Down or SHAP 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. Find information how to use this function here: https://pbiecek.github.io/ema/breakDown.html.

Usage

predict_parts(explainer, new_observation, ..., type = "break_down")

predict_parts_oscillations(explainer, new_observation, ...)

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, ..., type = "break_down")

Arguments

explainer

a model to be explained, preprocessed by the 'explain' function

new_observation

a new observarvation for which predictions need to be explained

...

other parameters that will be passed to iBreakDown::break_down

type

the type of variable attributions. Either shap, oscillations, break_down or break_down_interactions.

Value

Depending on the type there are different classess of the resulting object. It's a data frame with calculated average response.

References

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

Examples

Run this code
# NOT RUN {
new_dragon <- data.frame(year_of_birth = 200,
     height = 80,
     weight = 12.5,
     scars = 0,
     number_of_lost_teeth  = 5)

dragon_lm_model4 <- lm(life_length ~ year_of_birth + height +
                                     weight + scars + number_of_lost_teeth,
                       data = dragons)
dragon_lm_explainer4 <- explain(dragon_lm_model4, data = dragons, y = dragons$year_of_birth,
                                label = "model_4v")
dragon_lm_predict4 <- predict_parts_break_down(dragon_lm_explainer4,
                new_observation = new_dragon)
head(dragon_lm_predict4)
plot(dragon_lm_predict4)

# }
# NOT RUN {
library("ranger")
dragon_ranger_model4 <- ranger(life_length ~ year_of_birth + height +
                                               weight + scars + number_of_lost_teeth,
                                 data = dragons, num.trees = 50)
dragon_ranger_explainer4 <- explain(dragon_ranger_model4, data = dragons, y = dragons$year_of_birth,
                                label = "model_ranger")
dragon_ranger_predict4 <- predict_parts_break_down(dragon_ranger_explainer4,
                                                          new_observation = new_dragon)
head(dragon_ranger_predict4)
plot(dragon_ranger_predict4)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab