library("DALEX")
library("ingredients")
model_titanic_glm <- glm(survived ~ age + fare,
data = titanic_imputed, family = "binomial")
# \donttest{
explain_titanic_glm <- explain(model_titanic_glm,
data = titanic_imputed[,-8],
y = titanic_imputed[,8])
cp_rf <- ceteris_paribus_2d(explain_titanic_glm, titanic_imputed[1,],
variables = c("age", "fare", "sibsp"))
head(cp_rf)
plot(cp_rf)
library("ranger")
set.seed(59)
apartments_rf_model <- ranger(m2.price ~., data = apartments)
explainer_rf <- explain(apartments_rf_model,
data = apartments_test[,-1],
y = apartments_test[,1],
label = "ranger forest",
verbose = FALSE)
new_apartment <- apartments_test[1,]
new_apartment
wi_rf_2d <- ceteris_paribus_2d(explainer_rf, observation = new_apartment,
variables = c("surface", "floor", "no.rooms"))
head(wi_rf_2d)
plot(wi_rf_2d)
# }
Run the code above in your browser using DataLab