XAI in Python with dalex

Przemyslaw Biecek
3 min readApr 10, 2020
The dalex is the Python library developed by Wojciech Kretowicz and Hubert Baniecki for Explanatory Model Analysis / eXplainable Artificial Intelligence.

In MI2DataLab we have built many tools for the exploration, explanation and visualization of machine learning models. The latest product is the dalex package for Python developed by Wojciech Kretowicz and Hubert Baniecki.

It is written from scratch reimplementation of the DALEX package for R with identical functionalities and underlying philosophy. All algorithms have been rewritten to the Python and interactive plots are available through the plotly module.

Installation of the package

The latest version of the dalex package can be installed from a pip. The installation is very simple.

pip install dalex

Example use

We are still working on documentation and examples, so any feedback and suggestion will be welcome. For now we have:

An example Variable Importance plot. See more examples here
An example Partial Dependence and Accumulated Local Effect plot. See more examples here
An example Break Down plot. See more examples here

All available functions are described in the open ebook Explanatory Model Analysis.


The R environment has a fantastic data visualization system. Once the pioneer of statistical graphics was its package graphics, then package lattice and now its ggplot2. No wonder that for R there are many great tools for visualizing machine learning models, like pdp, ALEplot, condvis, lime, DALEX, iml, ROCR, modelStudio, regtools, vip, auditor, arena, modelDown and many others.

But what if we have a model built in Python, for example in scikit-learn?
In MI2DataLab we have made several tools to visualize in R models built in Python like DALEXtra and pyDALEX. Each of them required installation of both R and Python, which pose a challenge when it comes to maintaining both environments. In order to make it easier to explain the models built in scikit-learn or other Python libraries, a DALEX clone for Python was created.

There are already many great tools for XAI in Python, such as ELI5, LIME, SHAP, AIX360, tf-explain or interpretml. The advantage of the dalex package is that it is based on the expandable grammar of Explanatory Model Analysis process.

If you have an idea for an extension or find an error, let us know. Post an issue on https://github.com/ModelOriented/DALEX/.



Przemyslaw Biecek

Interested in innovations in predictive modeling. Posts about eXplainable AI, IML, AutoML, AutoEDA and Evidence-Based Machine Learning. Part of r-bloggers.com.