<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/predicting-flu-deaths-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/12/predicting-flu-deaths.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><a target="_blank" rel="nofollow" href="https://www.wired.com/2015/10/can-learn-epic-failure-google-flu-trends/">As Google learned</a>, predicting the spread of influenza, even with mountains of data, is notoriously difficult. Nonetheless, bioinformatician and R user Shirin Glander has created a two-part <a target="_blank" rel="nofollow" href="https://shiring.github.io/machine_learning/2016/11/27/flu_outcome_ML_post">tutorial about predicting flu deaths with R</a> (<a target="_blank" rel="nofollow" href="https://shiring.github.io/machine_learning/2016/12/02/flu_outcome_ML_2_post">part 2 here</a>). The analysis is based on just 136 cases of <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/outbreaks/versions/1.1.0/topics/fluH7N9.china.2013">influenza A H7N9 in China in 2013</a> (data provided in the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/outbreaks/">outbreaks package</a>) so the intent was not to create a generally predictive model, but by providing all of the R code and graphics Shirin has created a useful example of real-word predictive modeling with R.</p>
<p>The tutorial covers loading and cleaning the data (including a nice example of using the mice package to impute missing values) and begins with some exploratory data visualizations. I was particularly impressed by the use of density charts (using the <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/ggplot2/versions/2.2.0/topics/geom_density_2d">stat_density2d</a> ggplot2 aesthetic) to highlight differences in the scatterplots of flu cases ending in death and recovery.</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8bd969d970b-pi"><img title="Influenza" alt="Influenza" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8bd969d970b-800wi" border="0"></a></p>
<p>For the statistical analysis, Shirin applies several different kinds of predictive models, including:</p>
<ul>
<li>Decision trees (implemented using <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/rpart/versions/4.1-10/topics/rpart">rpart</a> and visualized using <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/rattle/versions/4.1.0/topics/fancyRpartPlot">fancyRpartPlot</a> from the <a target="_blank" rel="nofollow" href="http://rattle.togaware.com/">rattle package</a>)</li>
<li>Random Forests (using <a target="_blank" rel="nofollow" href="https://www.rdocumentation.org/packages/caret/versions/6.0-73/topics/train">caret</a>'s &quot;rf&quot; training method)</li>
<li>Elastic-Net Regularized Generalized Linear Models (using caret's &quot;glmnet&quot; training method)</li>
<li>K-nearest neighbors clustering (using caret's &quot;kknn&quot; training method)</li>
<li>Penalized Discriminant Analysis (using caret's &quot;pda&quot; training method)</li>
<li>and in Part 2, <a target="_blank" rel="nofollow" href="https://shiring.github.io/machine_learning/2016/12/02/flu_outcome_ML_2_post">Extreme gradient boosting</a> using the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/xgboost/">xgboost package</a> and various preprocessing techniques from the caret package</li>
</ul>
<p>Due to the limited data size, there's not too much difference between the models: in each case, 13-15 of the 23 cases were classified correctly. Nonetheless, the post provides a useful template for applying several different model types to the same data set, and using the power of the <a target="_blank" rel="nofollow" href="https://mran.microsoft.com/package/caret/">caret package</a> to normalize the data and optimize the models. </p>
<p>(By the way, if you like the style of Shirin's blog, she's also created a useful guide to <a target="_blank" rel="nofollow" href="https://shiring.github.io/blogging/2016/12/04/diy_your_own_blog">creating an R blog using Github, JekyllBootstrap, and RMarkdown</a>.)</p>
<p>For Shirin's complete analyses of the flu data, including the R code, follow the links below. </p>
<p>Shirin's playgRound: <a target="_blank" rel="nofollow" href="https://shiring.github.io/machine_learning/2016/11/27/flu_outcome_ML_post">Can we predict flu deaths with Machine Learning and R?</a> (<a target="_blank" rel="nofollow" href="https://shiring.github.io/machine_learning/2016/12/02/flu_outcome_ML_2_post">part 2</a>) (<a target="_blank" rel="nofollow" href="https://thomaswdinsmore.com/about-this-blog/">via</a> Thomas Dinsmore's ML/DL blog) </p>
</div>
<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://blog.revolutionanalytics.com/2016/12/predicting-flu-deaths.html"> Revolutions</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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/3MAWQ-FMyxM"></a></div>