Book Image

Mastering Machine Learning with R, Second Edition - Second Edition

Book Image

Mastering Machine Learning with R, Second Edition - Second Edition

Overview of this book

This book will teach you advanced techniques in machine learning with the latest code in R 3.3.2. You will delve into statistical learning theory and supervised learning; design efficient algorithms; learn about creating Recommendation Engines; use multi-class classification and deep learning; and more. You will explore, in depth, topics such as data mining, classification, clustering, regression, predictive modeling, anomaly detection, boosted trees with XGBOOST, and more. More than just knowing the outcome, you’ll understand how these concepts work and what they do. With a slow learning curve on topics such as neural networks, you will explore deep learning, and more. By the end of this book, you will be able to perform machine learning with R in the cloud using AWS in various scenarios with different datasets.
Table of Contents (23 chapters)
Title Page
About the Author
About the Reviewers
Packt Upsell
Customer Feedback

Model evaluation and selection

We will begin by creating our training and testing sets, then create a random forest classifier as our base model. After evaluating its performance, we will move on and try the one-versus-rest classification method and see how it performs. We split our data 70/30. Also, one of the unique things about the mlr package is its requirement to put your training data into a "task" structure, specifically a classification task. Optionally, you can place your test set in a task as well.

A full list of models is available here, plus you can also utilize your own:

    > library(caret) #if not already loaded

    > set.seed(502)

    > split <- createDataPartition(y = df$class, p = 0.7, list = F)

    > train <- df[split, ]

    > test <- df[-split, ]

    > wine.task <- makeClassifTask(id = "wine", data = train, target = 

Random forest

With our training...