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

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(xgboost)
library(EIX)

Fit a xgboost to the titanic imputed data.

library("Matrix")
X <- sparse.model.matrix(survived ~ . - 1,  data = titanic_imputed)


xgb_model <- xgboost(X, titanic_imputed$survived, nrounds = 10, params = list(objective = "binary:logistic"), prediction = TRUE)
## [1]  train-error:0.168555 
## [2]  train-error:0.168101 
## [3]  train-error:0.168101 
## [4]  train-error:0.167195 
## [5]  train-error:0.164024 
## [6]  train-error:0.160852 
## [7]  train-error:0.157227 
## [8]  train-error:0.157680 
## [9]  train-error:0.153149 
## [10] train-error:0.149977

Model parts

Interaction measure

interactions <- interactions(xgb_model, X, option = "interactions")
plot(interactions)

Variable Importance

importance <- importance(xgb_model, X, option = "both")
plot(importance)

Predict parts

Interaction based explanation of single observation

new_observation <- X[27,]
wf <- waterfall(xgb_model, new_observation, titanic_imputed[27,], option = "interactions")
plot(wf)

Model diagnostics

lolli <- lollipop(xgb_model, X)
plot(lolli, threshold=0.02)

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] Matrix_1.2-18    EIX_1.1          xgboost_0.90.0.2
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.1.0   sjlabelled_1.1.6   xfun_0.12          mycor_0.1.1       
##  [5] purrr_0.3.3        reshape2_1.4.3     splines_4.0.2      lattice_0.20-40   
##  [9] colorspace_1.4-1   vctrs_0.3.2        generics_0.0.2     htmltools_0.4.0   
## [13] yaml_2.2.1         mgcv_1.8-31        rlang_0.4.7        pillar_1.4.4      
## [17] glue_1.4.1         gdtools_0.2.2      RColorBrewer_1.1-2 uuid_0.1-4        
## [21] lifecycle_0.2.0    plyr_1.8.6         stringr_1.4.0      sjmisc_2.8.5      
## [25] munsell_0.5.0      gtable_0.3.0       htmlwidgets_1.5.1  evaluate_0.14     
## [29] labeling_0.3       DALEX_1.3.1.1      knitr_1.28         iBreakDown_1.2.0  
## [33] ggiraph_0.7.8      Rcpp_1.0.4.6       scales_1.1.1       ppcor_1.1         
## [37] farver_2.0.3       systemfonts_0.2.3  ggplot2_3.3.2      digest_0.6.25     
## [41] stringi_1.4.6      ggrepel_0.8.2      insight_0.9.0      dplyr_1.0.1       
## [45] grid_4.0.2         tools_4.0.2        magrittr_1.5       tibble_3.0.1      
## [49] crayon_1.3.4       tidyr_1.0.2        pkgconfig_2.0.3    ellipsis_0.3.1    
## [53] MASS_7.3-51.6      data.table_1.12.8  rmarkdown_2.1      R6_2.4.1          
## [57] ggiraphExtra_0.2.9 nlme_3.1-140       compiler_4.0.2