This report aims to present the capabilities of the package auditor.

The document is a part of the paper “Landscape of R packages for eXplainable Machine Learning”, S. Maksymiuk, A. Gosiewska, and P. Biecek. (https://arxiv.org/abs/2009.13248). It contains a real life use-case with a hand of titanic_imputed data set described in Section Example gallery for XAI packages of the article.

We did our best to show the entire range of the implemented explanations. Please note that the examples may be incomplete. If you think something is missing, feel free to make a pull request at the GitHub repository MI2DataLab/XAI-tools.

The list of use-cases for all packages included in the article is here.

Load titanic_imputed data set.

data(titanic_imputed, package = "DALEX")

head(titanic_imputed)
##   gender age class    embarked  fare sibsp parch survived
## 1   male  42   3rd Southampton  7.11     0     0        0
## 2   male  13   3rd Southampton 20.05     0     2        0
## 3   male  16   3rd Southampton 20.05     1     1        0
## 4 female  39   3rd Southampton 20.05     1     1        1
## 5 female  16   3rd Southampton  7.13     0     0        1
## 6   male  25   3rd Southampton  7.13     0     0        1
library(auditor)
library(randomForest)

Fit a forest type model to the titanic imputed data.

rf_model <- randomForest::randomForest(as.factor(survived)~., data = titanic_imputed)
gbm_model <- gbm::gbm(survived~., data = titanic_imputed, distribution = "bernoulli")

Model Diagnostics

Half-normal plots

exp <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
hf <- model_halfnormal(exp)
plot_halfnormal(hf)

LIFT curve - One model

exp <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
eva_rf <- model_evaluation(exp)
plot(eva_rf, type = "lift")

LIFT curve - Two models

exp_rf <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
exp_gbm <- DALEX::explain(gbm_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
eva_rf <- model_evaluation(exp_rf)
eva_gbm <- model_evaluation(exp_gbm)
plot(eva_gbm, eva_rf, type = "lift")

Observed vs Predicted - One model

exp <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp)
plot(res_rf, type = "prediction")

Observed vs Predicted - Two models

exp_rf <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
exp_gbm <- DALEX::explain(gbm_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp_rf)
res_gbm <- model_residual(exp_gbm)
plot(res_gbm, res_rf, type = "prediction")

Variable vs Predicted - One model

exp <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp)
plot(res_rf, type = "prediction", variable = "fare")

Variable vs Predicted - Two models

exp_rf <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
exp_gbm <- DALEX::explain(gbm_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp_rf)
res_gbm <- model_residual(exp_gbm)
plot(res_gbm, res_rf, type = "prediction", variable = "fare")

Density of residuals - One model

exp <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp)
plot(res_rf, type = "residual_density")

Correlation of models

exp_rf <- DALEX::explain(rf_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
exp_gbm <- DALEX::explain(gbm_model, data = titanic_imputed, y = titanic_imputed$survived, verbose = FALSE)
res_rf <- model_residual(exp_rf)
res_gbm <- model_residual(exp_gbm)
plot(res_gbm, res_rf, type = "correlation")

Session info

sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 17763)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=Polish_Poland.1250  LC_CTYPE=Polish_Poland.1250   
## [3] LC_MONETARY=Polish_Poland.1250 LC_NUMERIC=C                  
## [5] LC_TIME=Polish_Poland.1250    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] randomForest_4.6-14 auditor_1.3.0      
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.4.6     pillar_1.4.4     compiler_4.0.2   tools_4.0.2     
##  [5] digest_0.6.25    lattice_0.20-40  evaluate_0.14    lifecycle_0.2.0 
##  [9] tibble_3.0.1     gtable_0.3.0     pkgconfig_2.0.3  rlang_0.4.7     
## [13] Matrix_1.2-18    ggrepel_0.8.2    yaml_2.2.1       gbm_2.1.8       
## [17] xfun_0.12        gridExtra_2.3    stringr_1.4.0    dplyr_1.0.1     
## [21] knitr_1.28       generics_0.0.2   vctrs_0.3.2      grid_4.0.2      
## [25] tidyselect_1.1.0 glue_1.4.1       R6_2.4.1         DALEX_1.3.1.1   
## [29] survival_3.1-11  rmarkdown_2.1    hnp_1.2-6        farver_2.0.3    
## [33] ggplot2_3.3.2    purrr_0.3.3      magrittr_1.5     splines_4.0.2   
## [37] scales_1.1.1     ellipsis_0.3.1   htmltools_0.4.0  MASS_7.3-51.6   
## [41] colorspace_1.4-1 labeling_0.3     stringi_1.4.6    munsell_0.5.0   
## [45] crayon_1.3.4