library("DALEX")
library("ingredients")
library("ranger")
# \donttest{
apartments_rf_model <- ranger(m2.price ~., data = apartments)
explainer_rf <- explain(apartments_rf_model,
data = apartments_test[,-1],
y = apartments_test[,1],
verbose = FALSE)
new_apartment <- apartments_test[1,]
new_apartment
wi_rf_2d <- ceteris_paribus_2d(explainer_rf, observation = new_apartment)
head(wi_rf_2d)
plot(wi_rf_2d)
plot(wi_rf_2d, add_contour = FALSE)
plot(wi_rf_2d, add_observation = FALSE)
plot(wi_rf_2d, add_raster = FALSE)
# HR data
model <- ranger(status ~ gender + age + hours + evaluation + salary, data = HR,
probability = TRUE)
pred1 <- function(m, x) predict(m, x)$predictions[,1]
explainer_rf_fired <- explain(model,
data = HR[,1:5],
y = as.numeric(HR$status == "fired"),
predict_function = pred1,
label = "fired")
new_emp <- HR[1,]
new_emp
wi_rf_2d <- ceteris_paribus_2d(explainer_rf_fired, observation = new_emp)
head(wi_rf_2d)
plot(wi_rf_2d)
# }
Run the code above in your browser using DataLab