<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/r-code-to-accompany-real-world-machine-learning-chapter-3/"></div></div><div><a data-url="https://www.r-bloggers.com/r-code-to-accompany-real-world-machine-learning-chapter-3/" data-counturl="https://www.r-bloggers.com/r-code-to-accompany-real-world-machine-learning-chapter-3/" data-count="horizontal" data-text="R code to accompany Real-World Machine Learning (Chapter 3)" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://feedproxy.google.com/~r/DataProne-R/~3/lsL1PXWtvCg/real-world-machine-learning-with-R-chapter-3.html"> data prone - R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Abstract</h2>
<p>The rwml-R Github repo is updated with R code to accompany Chapter 3 of the book “Real-World Machine Learning” by Henrik Brink, Joseph W. Richards, and Mark Fetherolf.</p>
<h2>Survivors on the Titanic</h2>
<p>The Titanic Passengers dataset is used to illustrate various processes used<br>
to prepare data for modeling, including<br>
conversion of <code>factor</code> variables to dummy variables. For example, the code<br>
to produce the<br>
following table of processed data is provided:</p>
<table>
<thead>
<tr>
<th>Survived.yes</th>
<th>Pclass</th>
<th>Sex.male</th>
<th>Age</th>
<th>SibSp</th>
<th>Parch</th>
<th>Embarked.Q</th>
<th>Embarked.S</th>
<th>sqrtFare</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>3</td>
<td>1</td>
<td>22</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>2.692582</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>0</td>
<td>38</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>8.442944</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>0</td>
<td>26</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>2.815138</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>0</td>
<td>35</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>7.286975</td>
</tr>
<tr>
<td>0</td>
<td>3</td>
<td>1</td>
<td>35</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>2.837252</td>
</tr>
<tr>
<td>0</td>
<td>3</td>
<td>1</td>
<td>-1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>2.908316</td>
</tr>
</tbody>
</table>
<p>I also go “off-script” a bit (do some things not contained in the book) and<br>
demonstrate some useful visualization, modeling, and performance<br>
measuring techniques available with the<br>
<a target="_blank" href="http://topepo.github.io/caret/"><code>caret</code></a> and <a target="_blank" href="https://cran.r-project.org/web/packages/AppliedPredictiveModeling/index.html"><code>AppliedPredictiveModeling</code></a> packages.</p>
<h2>MNIST database of handwritten digits</h2>
<p>A k-nearest neighbors classifier (from the <code>kknn</code> package) is used to<br>
predict the numbers represented in the MNIST database of handwritten digits.<br>
Examples of the types of digits present in the dataset and the R code to<br>
display them:</p>
<p></p>
<p><img alt="Figure generated by above code" src="https://i2.wp.com/padamson.github.io/assets/figure3_10.png?w=456" data-recalc-dims="1"></p>
<h2>Auto MPG dataset</h2>
<p>As an example of a linear regression analysis, the Auto MPG dataset introduced<br>
in Chapter 2 resurfaces and fuel economy is predicted from origin, year of<br>
production, and performance characteristics such as horsepower and engine<br>
displacement.</p>
<h2>As always, feedback is welcome</h2>
<p>As always, I’d love to hear from you if you find the project helpful or if you<br>
have any suggestions. Please leave a comment below or use the Tweet button.<br>
Also, feel free to fork the <a target="_blank" href="https://github.com/padamson/rwml-R">rwml-R repo</a><br>
and submit a pull request if you wish to contribute.</p>
<p><a data-style="mega" target="_blank" href="https://github.com/padamson/rwml-R/archive/master.zip" data-icon="octicon-cloud-download">Download</a><br>
<a data-style="mega" data-count-href="http://feedproxy.google.com/padamson/rwml-R/network" data-count-aria-label="# forks on GitHub" target="_blank" data-count-api="/repos/padamson/rwml-R#forks_count" href="https://github.com/padamson/rwml-R/fork" data-icon="octicon-repo-forked">Fork</a></p>
<p><img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/DataProne-R/~4/lsL1PXWtvCg"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/r-code-to-accompany-real-world-machine-learning-chapter-3/"></div></div><div><a data-url="https://www.r-bloggers.com/r-code-to-accompany-real-world-machine-learning-chapter-3/" data-counturl="https://www.r-bloggers.com/r-code-to-accompany-real-world-machine-learning-chapter-3/" data-count="vertical" data-text="R code to accompany Real-World Machine Learning (Chapter 3)" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://feedproxy.google.com/~r/DataProne-R/~3/lsL1PXWtvCg/real-world-machine-learning-with-R-chapter-3.html"> data prone - R</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/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=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/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/RZTYHFZVYMY"></a></div>