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
Credits
About the Author
About the Reviewers
Packt Upsell
Customer Feedback
Preface
16
Sources

Data manipulation with dplyr


Over the past couple of years I have been using dplyr more and more to manipulate and summarize data. It is faster than using the base functions, allows you to chain functions, and once you are familiar with it has a more user-friendly syntax. In my experience, just a few functions can accomplish the majority of your data manipulation needs. Install the package as described above, then load it into the R environment.

    > library(dplyr)

Let's explore the iris dataset available in base R. Two of the most useful functions are summarize() and group_by(). In the code that follows, we see how to produce a table of the mean of Sepal.Length grouped by the Species. The variable we put the mean in will be called average.

    > summarize(group_by(iris, Species), average = mean(Sepal.Length))
      # A tibble: 3 X 2
         Species average
          <fctr>   <dbl>
    1     setosa   5.006
    2 versicolor   5.936
    3  virginica   6.588

There are a number...