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

Using R

With all systems ready to launch, let's start our first commands. R will take both the strings in quotes or simple numbers. Here, we will put one command as a string and one command as a number. The output is the same as the input:

> "Let's Go Sioux!"
[1] "Let's Go Sioux!"

> 15
[1] 15

R can also act as a calculator:

> ((22+5)/9)*2
[1] 6

Where R starts to shine is in the creation of vectors. Here, we will put the first 10 numbers of the Fibonacci sequence in a vector using the c() function, which stands for combining the values to a vector or list (concatenate):

> c(0, 1, 1, 2, 3, 5, 8, 13, 21, 34) #Fibonacci sequence
 [1]  0  1  1  2  3  5  8 13 21 34

Note that in this syntax, I included a comment, Fibonacci sequence. In R, anything after the # key on the command line is not executed.

Now, let's create an object that contains these numbers of the sequence. You can assign any vector or list to an object. In most R code, you will see the assign symbol as <-, which is read...