dime: Deep Interactive Model Explanations

Hubert Baniecki created an awesome package dime for serverless HTML interactive model exploration. The experimental version is at Github, here is the pkgdown website. It is a part of the DrWhy.AI project.

How does it work?

With the DALEX package you can create local and global model explanations for machine learning models. Each explanation can be visualized with a genetic plot() function.
Hubert created a generic plotD3() function which turns each explanation into an interactive D3 plot (with the help of r2d3 package). With the dime package you can combine few interactive explanations into a single dashboard. And the dashboard is serverless, you can host it at github or anywhere.

For example, the gif below shows how to combine a break down plot (local feature attribution) with ceteris paribus profiles (detailed analysis of a single variable). You can click a variable of interest to activate an appropriate ceteris paribus profile (click to play).

With the dime package you can combine any number of interactive widgets into a single dashboard. You can connect local, global explanations or EDA tools like histograms or barplots.

It’s very easy to generate such website. Just create an explainer and call the modelStudio() function.

Find examples and R codes here: https://github.com/ModelOriented/dime/blob/master/README.md

The dime package is still in the experimental phase. Your feedback is welcomed. Feel free to submit an issue with comments or ideas.

Learn about XAI in R with ,,Predictive Models: Explore, Explain, and Debug”

XAI (eXplainable artificial intelligence) is a fast growing and super interesting area.
Working with complex models generates lots of problems with model validation (on test data performance is great but drops at production), model bias, lack of stability and many others. We need more than just local explanations for predictive models.

The more complex are models the better tools are needed to understand how models are working, explore model behaviour and debug potential errors.

Two years ago I’ve initiated work on the DALEX package. Library packed with functions for local and global model exploration.
Over the time the package went through few architectural changes and now it is part of a larger universe of tools for model exploration developed at MI2DataLab with an increasing support of external contributors (join us).

To explain our philosophy behind the model exploration we (together with Tomasz Burzykowski from Hasselt) started a book ,,Predictive Models: Explore, Explain, and Debug’’.

First part, devoted to local exploration, is ready to read. It explains how to use DALEX with iBreakDown and ingredients packages for instance level explanations.
Later we will describe other packages from our universe.

Find the book-down version of here.

Find a one-page-cheatsheet here.

Let us improve these descriptions by adding pull requests or issues at the GitHub repo.
One day there will be a paper version 😉

Break Down: model explanations with interactions and DALEX in the BayArea

The breakDown package explains predictions from black-box models, such as random forest, xgboost, svm or neural networks (it works for lm and glm as well). As a result you gets decomposition of model prediction that can be attributed to particular variables.

The version 0.3 has a new function `break_down`. It identifies pairwise interactions of variables. So if the model is not additive, then instead of seeing effects of single variables you will see effects for interactions.
It’s easy to use this function. See an example below.
HR is an artificial dataset. The `break_down` function correctly identifies interaction between gender and age. Find more examples in the documentation.

#
# Create a model for classification
library("DALEX")
library("randomForest")
model <- randomForest(status ~ . , data = HR)

#
# Create a DALEX explainer
explainer_rf_fired <- explain(model,
                 data = HR,  y = HR$status == "fired",
                 predict_function = function(m,x) predict(m,x, type = "prob")[,1])

#
# Calculate variable attributions
new_observation <- HRTest[1,]
library("breakDown")
bd_rf <- break_down(explainer_rf_fired,
                 new_observation,
                 keep_distributions = TRUE)

bd_rf
#>                        contribution
#> (Intercept)                   0.386
#> * hours = 42                  0.231
#> * salary = 2                 -0.216
#> * age:gender = 58:male        0.397
#> * evaluation = 2             -0.019
#> final_prognosis               0.778
#> baseline:  0 

plot(bd_rf)

Figure below shows that a single prediction was decomposed into 4 parts. One of them is related to the interaction between age and gender.

BreakDown is a part of DALEXverse – collection of tools for visualisation, exploration and explanation of complex machine learning models.

Till the end of September I am visiting UC Davis and UC Berkeley. Happy to talk about DALEX explainers, XAI and related stuff.
So, if you want to talk about interpretability of complex ML models, just let me know.

Yes, it’s part of the DALEX invasion 😉
Thanks to the H2020 project RENOIR.