# NOT RUN {
library("DALEX")
# Toy examples, because CRAN angels ask for them
titanic <- na.omit(titanic)
model_titanic_glm <- glm(survived == "yes" ~ gender + age + fare,
data = titanic, family = "binomial")
explain_titanic_glm <- explain(model_titanic_glm,
data = titanic[,-9],
y = titanic$survived == "yes")
pdp_rf <- conditional_dependency(explain_titanic_glm, N = 50)
plot(pdp_rf)
# }
# NOT RUN {
library("titanic")
library("randomForest")
titanic_small <- titanic_train[,c("Survived", "Pclass", "Sex", "Age",
"SibSp", "Parch", "Fare", "Embarked")]
titanic_small$Survived <- factor(titanic_small$Survived)
titanic_small$Sex <- factor(titanic_small$Sex)
titanic_small$Embarked <- factor(titanic_small$Embarked)
titanic_small <- na.omit(titanic_small)
rf_model <- randomForest(Survived ~ Pclass + Sex + Age + SibSp + Parch + Fare + Embarked,
data = titanic_small)
explainer_rf <- explain(rf_model, data = titanic_small,
y = titanic_small$Survived == "1", label = "RF")
pdp_rf <- conditional_dependency(explainer_rf)
plot(pdp_rf)
# }
Run the code above in your browser using DataLab