BASIC XAI with DALEX — Part 4: Break Down method
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
BASIC XAI
BASIC XAI with DALEX — Part 4: Break Down method
Introduction to model exploration with code examples for R and Python.
Welcome to the “BASIC XAI with DALEX” series.
In this post, we present the Break Down method, the model agnostic method, which is the one we can use for any type of model.
Previous parts of this series are available:
- BASIC XAI with DALEX — Part 1: Introduction.
- BASIC XAI with DALEX — Part 2: Permutation-based variable importance.
- BASIC XAI with DALEX — Part 3: Partial Dependence Profile
So, shall we start?
First — What it is Break Down?
The previous methods we discussed concerned the global exploration of models. We looked at the importance of variables and Partial Dependence Profiles. Now, we move on to local explanations, i.e., those concerning a specific observation. We may consider real estate, patient, bank, or telecommunication client. The Break Down method is one of the local explanations; it indicates for a selected observation a contribution of variables into models’ prediction.
Second — Idea of Break Down
The basic idea is to calculate the contribution of variable in prediction of f(x) as changes in the expected model response given other variables. This means that we start with the mean expected model response of the model, successively adding variables to the conditioning. Of course, the order in which the variables are arranged also influences the contribution values. If our model is additive, the arrangement of individual variables and values will be the same. If we have a non-additive model with p variables, we have p! orders, it is complicated by calculation.
How does it calculate in Break Down method?
Let’s take one observation from the apartments dataset.
m2.price 5897 construction.year 1953 surface 25 floor 3 no.rooms 1
We start from the average value of the prediction, i.e. for each observation in the set we calculate the prediction and then average it. In the next step we select all observations for which the construction.year variable takes the value 1953. For these variables we calculate the average prediction. The difference between this value and the average prediction for the model is the contribution of the variable construction.year. Then, from the apartments built in 1953, we select those that have a surface area of 25 and, similarly, we calculate the average prediction for these observations. At this point, we already determine on two variables, for other variables we proceed the same way.
The introduction more formally the Break Down method you can find in Biecek, P. and Burzykowski, T. Explanatory Model Analysis.
Third — let’s get a model in R and Python
Let’s write some code. We are still working on the DALEX apartments data. To calculate the Break Down method we use the predict_parts() function with type = ‘break_down’. We need the explainer object and the observation for which we want to calculate the explanation.
Let’s see now on the plot for this apartment. The biggest influence on the price of the apartment has the “Ochota” district, it is close to the city center. However, the price is negatively impacted by the fact that the apartment is not in the “Srodmiescie” district — city center. Moreover, the floor number equal 7 and the 93 meter squared area have a negative contribution to price.
In the next part, we will talk about Shapley values method.
Many thanks to Przemyslaw Biecek and Hubert Baniecki for their support on this blog.
If you are interested in other posts about explainable, fair, and responsible ML, follow #ResponsibleML on Medium.
In order to see more R related content visit https://www.r-bloggers.com
BASIC XAI with DALEX — Part 4: Break Down method was originally published in ResponsibleML on Medium, where people are continuing the conversation by highlighting and responding to this story.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.