# 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 {
# }
Run the code above in your browser using DataLab