<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/modeldown-a-website-generator-for-your-predictive-models/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://smarterpoland.pl/index.php/2018/06/modeldown-a-website-generator-for-your-predictive-models/"> English – SmarterPoland.pl</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img align="right" src="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/dalex-e1530258773217.png?w=250" data-recalc-dims="1">I love the <a rel="nofollow" href="https://github.com/r-lib/pkgdown" target="_blank">pkgdown</a> package. With a single line of code you can create a complete website with examples, vignettes and documentation for your package. Brilliant!</p>
<p>So what about a website generator for predictive models?<br>
Imagine that you can take a set of predictive models (generated with caret, mlr, glm, xgboost or randomForest, anything) and automagically generate a website with an exploration/documentation for these models. A documentation with <a rel="nofollow" href="https://github.com/pbiecek/archivist/" target="_blank">archvist</a> hooks to models, with tables and graphs for model performance explainers, conditional model response explainers or explainers for particular predictions. </p>
<p>During the summer semester three students from Warsaw University of Technology (Kamil Romaszko, Magda Tatarynowicz, Mateusz Urbański) developed <a rel="nofollow" href="https://github.com/MI2DataLab/modelDown" target="_blank">modelDown</a> package for R as an team project assignment. You can find the package <a rel="nofollow" href="https://github.com/MI2DataLab/modelDown" target="_blank">here</a>. Visit an example <a rel="nofollow" href="https://mi2datalab.github.io/modelDown_example/" target="_blank">website created with this package for four example models</a> (<a rel="nofollow" href="https://github.com/MI2DataLab/modelDown_example" target="_blank">instructions</a>). And read more about this package at its <a rel="nofollow" href="https://mi2datalab.github.io/modelDown/" target="_blank">pkgdown website</a> or below.</p>
<p>BTW: If you want to learn more about model explainers, please come to our DALEX workshops at <a rel="nofollow" href="http://www.whyr2018.pl/" target="_blank">WhyR? 2018 conference</a> in Wroclaw or <a rel="nofollow" href="https://user2018.r-project.org/" target="_blank">UseR! 2018 conference</a> in Brisbane.</p>
<p><b>Getting started with modelDown</b><br>
by <i>Kamil Romaszko, Magda Tatarynowicz, Mateusz Urbański</i></p>
<p><b>Introduction</b></p>
<p>Did you ever want to have one place where you can find information explaining your model? Or maybe you were missing a tool that can show difference in multiple models for the same dataset? Well, here comes modelDown package. By using DALEX package, it creates one html page with plots and information related to the model(s) you want to analyze.</p>
<p>If you want to check out example website generated with modelDown, check out <a rel="nofollow" href="https://mi2datalab.github.io/modelDown_example" target="_blank">this link</a> (along with <a rel="nofollow" href="https://github.com/MI2DataLab/modelDown_example" target="_blank">script</a> that was used to create the html). Read on to see how to use package for your own models and what features it provides.</p>
<p>The examples presented here were generated for dataset HR_data from breakDown package (available on CRAN). The dataset contains various information about employees (for example their satisfaction from work or their salary). The information we predict is whether they left the company.</p>
<p><b>Installation</b><br>
First things first – how can you use this package? Install it from github:</p>

<pre>devtools::install_github(&quot;MI2DataLab/modelDown&quot;)</pre>

<p><span></span></p>
<p>When you have the package successfully installed, you need to create DALEX explainers for you models. Here is a simple example. Please refer to <a rel="nofollow" href="https://github.com/pbiecek/DALEX" target="_blank">DALEX package documentation</a> in order to learn more.</p>

<pre># assuming you have two models: glm_model and ranger_model for HR_data
explainer_glm &lt;- DALEX::explain(glm_model, data = HR_data, y = HR_data$left)
explainer_ranger &lt;- DALEX::explain(ranger_model, data = HR_data, y = HR_data$left)</pre>
<p>Next, just pass all created explainers to function modelDown. For example:</p>

<pre>modelDown::modelDown(explainer_ranger, explainer_glm)</pre>

<p>That’s it! Now you should have your html page generated with default options.</p>
<p><b>Features</b></p>
<p>Let’s quickly describe the sections of your page. If you want to know more about how the plots are generated, again, check out DALEX package documentation.</p>
<p><i><b>Index page</b></i></p>
<p><img src="https://i1.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/s0.png?w=456" data-recalc-dims="1"></p>
<p>Always know your data before you analyze the model – the index page helps you do exactly that.</p>
<p>You can see basic information about your data, like dimensions and summary of all variables. For numerical variables there is some statistical data presented, for categorical ones you see how many observations were in each category.</p>
<p><i><b>Model Performance</b></i></p>
<p><img src="https://i1.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/s1-e1530258477106.png?w=456" data-recalc-dims="1"></p>
<p>The most general informations about how correct were the predictions.</p>
<p>For our two models – clearly ranger model has lower residual values, which suggests its better performance for this dataset.</p>
<p><i><b>Variable Importance</b></i></p>
<p><img src="https://i2.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/s2-e1530258466828.png?w=456" data-recalc-dims="1"></p>
<p>Variable importance plot is extremely useful when you want to see how removing single variable impacts the response – basically how important every variable is.</p>
<p>Here, it is clear that for linear model there are two most important variables – number_project and satisfaction_level. For ranger model, there are 4 most important variables. Also, for each model different variable was picked as the most important one.</p>
<p><i><b>Variable Response</b></i></p>
<p><img src="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/s3b-e1530260738888.png?w=456" data-recalc-dims="1"></p>
<p>In variable response plot you can see how one variable impacts response.</p>
<p>For example, for variable average_monthly_hours and glm model, there is a linear dependency – the more hours someone works, the greater chance he will leave the company. For ranger model, this is not so clear – chance of leaving drastically increases for people working more than 270 hours a month. By default the plots are generated for every variable, so you can make similar conclusions for all variables in the model.</p>
<p><i><b>Prediction BreakDown</b></i></p>
<p><img src="https://i0.wp.com/smarterpoland.pl/wp-content/uploads/2018/06/s5-e1530258435686.png?w=456" data-recalc-dims="1"></p>
<p>Prediction breakdown shows detailed informations for particular observations in a model.By default for each model one observation with worst predicted value is presented.</p>
<p>On the example, for ranger model the value of satisfaction_level had the biggest part in final response calculation. So even though this particular employee’s satisfaction level was lower than half of scale used to measure, he still didn’t leave the company. The model prediction was not correct in this case.</p>
<p>Prediction breakdown makes it easier to understand how model acted. It can be useful for tuning your model and improving its capabilities.</p>
<p><i><b>Summary</b></i></p>
<p>The idea of the package was to help you understand your models in a condensed and easy way. We hope that using this package will make models’ performance clear to you. Feel free to use it and provide your feedback.</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/06/modeldown-a-website-generator-for-your-predictive-models/"> 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/B6dmWSSaiFY" height="1"></a></div>