<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/applying-machine-learning-algorithms-exercises/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/09/15/applying-machine-learning-algorithms-exercises/"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2017/08/android-150996_960_720.png" target="_blank"><img sizes="(max-width: 150px) 100vw, 150px" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/08/android-150996_960_720-150x150.png?resize=150%2C150" alt="" class="wp-image-7740" data-recalc-dims="1"></a><strong>INTRODUCTION</strong></p>
<p>Dear reader,</p>
<p>If you are a newbie in the world of machine learning, then this tutorial is exactly what you need in order to introduce yourself to this exciting new part of the data science world.</p>
<p>This post includes a full machine learning project that will guide you step by step to create a “template,” which you can use later on other datasets.</p>
<p>Before proceeding, please follow our short <a rel="nofollow" href="http://www.r-exercises.com/2017/08/25/machine-learning-tutorial/" target="_blank">tutorial.<br>
</a><br>
Look at the examples given and try to understand the logic behind them. Then try to solve the exercises below using R and without looking at the answers. Then see the <a rel="nofollow" href="http://r-exercises.com/2017/09/15/applying-machine-learning-algorithms-exercises-solutions/" target="_blank">solutions</a> to check your answers.</p>
<p><strong>Exercise 1</strong></p>
<p>Create a list named “control” that runs a 10-fold cross-validation. <strong>HINT</strong>: Use <code>trainControl()</code>.</p>
<p><strong>Exercise 2</strong></p>
<p>Use the metric of “Accuracy” to evaluate models.</p>
<p><strong>Exercise 3</strong></p>
<p>Build the “LDA”, “CART”, “kNN”, “SVM” and “RF” models.</p>
<p><strong>Exercise 4</strong></p>
<p>Create a list of the 5 models you just built and name it “results”. <strong>HINT</strong>: Use <code>resamples()</code>.</p>
<div>
<aside><img src="http://www.r-exercises.com/2017/09/15/applying-machine-learning-algorithms-exercises/"></aside>
<div><strong>Learn more</strong> about machine learning in the online course <a rel="nofollow" href="http://www.r-exercises.com/product/beginner-to-advanced-guide-on-machine-learning-with-r-tool/" target="_blank">Beginner to Advanced Guide on Machine Learning with R Tool</a>. In this course you will learn how to:
<ul>
<li>Create a machine learning algorithm from a beginner point of view</li>
<li>Quickly dive into more advanced methods in an accessible pace and with more explanations</li>
<li>And much more</li>
</ul>
<p>This course shows a complete workflow start to finish. It is a great introduction and fallback when you have some experience.
</div>
</div>
<p><strong>Exercise 5</strong></p>
<p>Report the accuracy of each model by using the summary function on the list “results”. <strong>HINT</strong>: Use <code>summary()</code>.</p>
<p><strong>Exercise 6</strong></p>
<p>Create a plot of the model evaluation results and compare the spread and the mean accuracy of each model. <strong>HINT</strong>: Use <code>dotplot()</code>.</p>
<p><strong>Exercise 7</strong></p>
<p>Which model seems to be the most accurate?</p>
<p><strong>Exercise 8</strong></p>
<p>Summarize the results of the best model and print them. <strong>HINT</strong>: Use <code>print()</code>.</p>
<p><strong>Exercise 9</strong></p>
<p>Run the “LDA” model directly on the validation set to create a factor named “predictions”. <strong>HINT</strong>: Use <code>predict()</code>.</p>
<p><strong>Exercise 10</strong></p>
<p>Summarize the results in a confusion matrix. <strong>HINT</strong>: Use <code>confusionMatrix()</code>.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/08/25/machine-learning-tutorial/" title="How to prepare and apply machine learning to your dataset" target="_blank">How to prepare and apply machine learning to your dataset </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/09/01/summarizing-dataset-to-apply-machine-learning-exercises/" title="Summarizing dataset to apply machine learning – exercises" target="_blank">Summarizing dataset to apply machine learning – exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/09/08/visualizing-dataset-to-apply-machine-learning-exercises/" title="Visualizing dataset to apply machine learning-exercises" target="_blank">Visualizing dataset to apply machine learning-exercises </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</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://www.r-exercises.com/2017/09/15/applying-machine-learning-algorithms-exercises/"> R-exercises</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/s4NGcI3QxOQ" height="1"></a></div>