ModelOriented / ingredients

Effects and Importances of Model Ingredients
https://modeloriented.github.io/ingredients/
GNU General Public License v3.0
37 stars 19 forks source link

fix cp colors #128

Closed hbaniecki closed 4 years ago

hbaniecki commented 4 years ago

fixes #125

library("DALEX")
library("ingredients")
model_titanic_glm <- glm(survived ~ gender + age + fare,
                         data = titanic_imputed, family = "binomial")

explain_titanic_glm <- explain(model_titanic_glm,
                               data = titanic_imputed[,-8],
                               y = titanic_imputed[,8],
                               verbose = FALSE)

cp_glm <- ceteris_paribus(explain_titanic_glm, titanic_imputed[1,])
cp_glm

library("randomForest")
model_titanic_rf <- randomForest(survived ~.,  data = titanic_imputed)

explain_titanic_rf <- explain(model_titanic_rf,
                              data = titanic_imputed[,-8],
                              y = titanic_imputed[,8],
                              label = "Random Forest v7",
                              verbose = FALSE)

cp_rf <- ceteris_paribus(explain_titanic_rf, titanic_imputed[1,])
cp_rf

plot(cp_glm, cp_rf, variables = "age")
plot(cp_glm, cp_rf, variable_type='categorical', categorical_type = 'profiles')
plot(cp_glm, cp_rf, variable_type='categorical', categorical_type = 'lines')
plot(cp_glm, cp_rf, variable_type='categorical', categorical_type = 'bars')

plot(cp_glm)
plot(cp_rf, color = '_ids_')
plot(cp_rf, color = '_label_')

cp_glm2 <- ceteris_paribus(explain_titanic_glm, titanic_imputed[4,])
cp_glm2
plot(cp_glm2, cp_glm,  color = 'gender')
plot(cp_glm2, cp_glm,  variable_type = 'categorical', color="_ids_")
plot(cp_glm2, cp_glm,  variable_type = 'categorical', color="_ids_", categorical_type = 'bars')
plot(cp_glm2, cp_glm,  variable_type = 'categorical', color="_ids_", categorical_type = 'lines')
pbiecek commented 4 years ago

thanks