library("DALEX")
library("iBreakDown")
set.seed(1313)
model_titanic_glm <- glm(survived ~ gender + age + fare,
data = titanic_imputed, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
data = titanic_imputed,
y = titanic_imputed$survived,
label = "glm")
bd_glm <- local_attributions(explain_titanic_glm, titanic_imputed[1, ])
bd_glm
plotD3(bd_glm)
if (FALSE) {
## Not run:
library("randomForest")
m_rf <- randomForest(status ~ . , data = HR[2:2000,])
new_observation <- HR_test[1,]
new_observation
p_fun <- function(object, newdata){predict(object, newdata=newdata, type = "prob")}
bd_rf <- local_attributions(m_rf,
data = HR_test,
new_observation = new_observation,
predict_function = p_fun)
bd_rf
plotD3(bd_rf)
}
Run the code above in your browser using DataLab