This Monday we had a machine learning oriented meeting of Warsaw R Users. Prof Bernd Bischl from LMU gave an excellent overview of mlr package (machine learning in R), then I introduced DALEX (Descriptive mAchine Learning EXplanations) and Mateusz Staniak introduced live and breakDown packages.

The meeting pushed me to write down a gentle introduction to the DALEX package. You may find it here https://pbiecek.github.io/DALEX_docs/.

The introduction is written around a story based on Warsaw apartments data.

The story goes like that:

We have two models fitted to apartments data: a linear model and a randomForest model. It happens that both models have exactly identical root mean square for errors calculated on a validation dataset.

So an interesting question arise: *which model we should choose?*

The analysis of variable importance for both models reveals that variable *construction.year* is important for randomForest but is completely neglected by linear model.

New observation: *something is going on with construction.year*.

The analysis of model responses reveals that the relation between *construction.year* and price of square meter is nonlinear.

At this point it looks like the random forest model is the better one, since it captures relation, which the linear model do not see.

But (there is always but) when you audit residuals from the random forest model it turns out that it heavily under predicts prices of expensive apartments.

This is a very bad property for a pricing model. This may result in missed opportunities for larger profits.

New observation: *do not use this rf model for predictions*.

So, what to do?

DALEX shows that despite equal root mean squares of both models they are very different and capture different parts of the signal.

As we increase our understanding of the signal we are able to design a better model. And here we go.

This new liner model has much lower root mean square of residuals, as it is build on strengthens of both initial models.

All plots were created with DALEX explainers. Find R code and more details here.