<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/dalex-how-would-you-explain-this-prediction/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://smarterpoland.pl/index.php/2018/02/dalex-which-variables-influence-this-single-prediction/"> SmarterPoland.pl » English</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Last week I wrote about <a rel="nofollow" href="http://smarterpoland.pl/index.php/2018/02/dalex-conditional-single-variable-response-of-your-black-box-model/" target="_blank">single variable explainers</a> implemented in the DALEX package. They are useful to plot relation between a model output and a single variable. </p>
<p>But sometimes we are more focused on a single model prediction. If our model predicts possible drug response for a patient, we really need to know which factors drive the model prediction for a particular patient. For linear models it is relatively easy as the structure of the model is additive. In 2017 we have developed <a rel="nofollow" href="http://smarterpoland.pl/index.php/2017/12/explain-explain-explain/" target="_blank">breakDown</a> package for lm/glm models. </p>
<p>But how to explain/decompose/approximate predictions for any black box model?<br>
There are several approaches. The (probably) most known is <a rel="nofollow" href="https://arxiv.org/abs/1602.04938" target="_blank">LIME</a> with great examples for image and text data. There is an R port <a rel="nofollow" href="https://cran.r-project.org/web/packages/lime/index.html" target="_blank">lime</a> developed by Thomas Pedersen. In collaboration with Mateusz Staniak we developed <a rel="nofollow" href="https://github.com/MI2DataLab/live" target="_blank">live</a> package, similar approach, easy to use with models created by <a rel="nofollow" href="https://cran.r-project.org/web/packages/mlr/index.html" target="_blank">mlr</a> package.<br>
The other technique that can be used here are <a rel="nofollow" href="https://github.com/slundberg/shap" target="_blank">Shapley values</a> which use attribution theory/game theory to attribute effects of different variables for a single prediction. </p>
<p>Recently we have developed a yet another approach (paper under preparation, implemented in the breakDown version 0.4) that works in a model agnostic way (here you can check how to use it <a rel="nofollow" href="https://pbiecek.github.io/breakDown/articles/break_caret.html" target="_blank">for caret models</a>). You can play with it via the <em>single_prediction()</em> function in the <em>DALEX</em> package.<br>
Such decomposition is useful for many reasons mentioned in papers listed above (deeper understanding, validation, trust, etc).<br>
And, what is really extra about the DALEX package, you can compare contributions of different models on the same scale. </p>
<p>Let’s train three models (glm / gradient boosting model and random forest model) to predict quality of wine. These models are very different in structure. In the figure below, for a single wine, we compare predictions calculated by these models. For this single wine, for all models the most influential variable is the alcohol concentration as the wine has much higher concentration than average. Then pH and sulphates take second and third positions in all three models. Looks like models have some agreement even if they structure is very different.</p>
<p><a rel="nofollow" href="https://i2.wp.com/smarterpoland.pl/wp-content/uploads/2018/02/plot.single_prediction_explainer-19.png" target="_blank"><img alt="plot.single_prediction_explainer-19" src="https://i1.wp.com/smarterpoland.pl/wp-content/uploads/2018/02/plot.single_prediction_explainer-19-1024x633.png?w=450" class="wp-image-8576" data-recalc-dims="1"></a></p>
<p>If you want to learn more about DALEX package and decompositions for model predictions please consult following cheatsheet or the <a rel="nofollow" href="https://pbiecek.github.io/DALEX/" target="_blank">DALEX website</a>.</p>
<p>If you want to learn more about explainers in general, join our DALEX Invasion!<br>
Find our DALEX workshops at SER (Warsaw, April 2018), ERUM (Budapest, May 2018), WhyR (Wroclaw, June 2018) or UseR (Brisbane, July 2018).</p>
<p><a rel="nofollow" href="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2018/02/DALEX_single_prediction.png" target="_blank"><img alt="DALEX_single_prediction" src="https://i2.wp.com/smarterpoland.pl/wp-content/uploads/2018/02/DALEX_single_prediction-1024x776.png?w=450" class="wp-image-8577" data-recalc-dims="1"></a></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/02/dalex-which-variables-influence-this-single-prediction/"> SmarterPoland.pl » English</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/RpkdwevsUBQ" height="1"></a></div>