library("DALEX")
library("ingredients")
lm_model <- lm(m2.price ~., data = apartments)
explainer_lm <- explain(lm_model,
data = apartments[,-1],
y = apartments[,1],
verbose = FALSE)
fi_lm <- feature_importance(explainer_lm,
loss_function = DALEX::loss_root_mean_square, B = 1)
head(fi_lm)
plotD3(fi_lm)
# \donttest{
library("ranger")
rf_model <- ranger(m2.price~., data = apartments)
explainer_rf <- explain(rf_model,
data = apartments[,-1],
y = apartments[,1],
label = "ranger forest",
verbose = FALSE)
fi_rf <- feature_importance(explainer_rf, loss_function = DALEX::loss_root_mean_square)
head(fi_rf)
plotD3(fi_lm, fi_rf)
plotD3(fi_lm, fi_rf, split = "feature")
plotD3(fi_lm, fi_rf, max_vars = 3, bar_width = 16, scale_height = TRUE)
plotD3(fi_lm, fi_rf, max_vars = 3, bar_width = 16, split = "feature", scale_height = TRUE)
plotD3(fi_lm, margin = 0.2)
# }
Run the code above in your browser using DataLab