<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/break-down-model-explanations-with-interactions-and-dalex-in-the-bayarea/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://smarterpoland.pl/index.php/2018/09/break-down-model-explanations-with-interactions-and-dalex-in-the-bayarea/"> English – SmarterPoland.pl</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The <a rel="nofollow" href="https://github.com/pbiecek/breakDown" target="_blank">breakDown</a> 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. </p>
<p>The version 0.3 has a new function <code>break_down</code>. 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.<br>
It’s easy to use this function. See an example below.<br>
HR is an artificial dataset. The <a rel="nofollow" href="https://pbiecek.github.io/breakDown/reference/break_down.html" target="_blank"><code>break_down</code></a> function correctly identifies interaction between gender and age. Find more examples in the documentation.</p>

<pre>#
# Create a model for classification
library(&quot;DALEX&quot;)
library(&quot;randomForest&quot;)
model &lt;- randomForest(status ~ . , data = HR)

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

#
# Calculate variable attributions
new_observation &lt;- HRTest[1,]
library(&quot;breakDown&quot;)
bd_rf &lt;- 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)</pre>

<p>Figure below shows that a single prediction was decomposed into 4 parts. One of them is related to the interaction between age and gender.<br>
<img src="https://i1.wp.com/smarterpoland.pl/wp-content/uploads/2018/09/Screen-Shot-2018-09-17-at-11.04.08-AM-e1537208392994.png?w=456" data-recalc-dims="1"></p>
<p>BreakDown is a part of <a rel="nofollow" href="https://pbiecek.github.io/DALEX_docs/" target="_blank">DALEXverse</a> – collection of tools for visualisation, exploration and explanation of complex machine learning models. </p>
<p>Till the end of September I am visiting UC Davis and UC Berkeley. Happy to talk about DALEX explainers, XAI and related stuff.<br>
So, if you want to talk about interpretability of complex ML models, just <a rel="nofollow" href="https://www.linkedin.com/in/przemyslaw-biecek-5b41761/" target="_blank">let me know</a>.</p>
<p><img src="https://i2.wp.com/smarterpoland.pl/wp-content/uploads/2018/09/DALEX_invasion-e1537208417942.png?w=456" data-recalc-dims="1"></p>
<p>Yes, it’s part of the <a rel="nofollow" href="https://github.com/pbiecek/DALEX" target="_blank">DALEX</a> invasion <img alt="😉" src="https://i2.wp.com/s.w.org/images/core/emoji/11/72x72/1f609.png?w=456&ssl=1" class="wp-smiley" data-recalc-dims="1"><br>
Thanks to the H2020 project RENOIR.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://smarterpoland.pl/index.php/2018/09/break-down-model-explanations-with-interactions-and-dalex-in-the-bayarea/"> English – SmarterPoland.pl</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/zLXheFncs6U" height="1"></a></div>