Book Image

Learning Predictive Analytics with R

By : Eric Mayor
Book Image

Learning Predictive Analytics with R

By: Eric Mayor

Overview of this book

This book is packed with easy-to-follow guidelines that explain the workings of the many key data mining tools of R, which are used to discover knowledge from your data. You will learn how to perform key predictive analytics tasks using R, such as train and test predictive models for classification and regression tasks, score new data sets and so on. All chapters will guide you in acquiring the skills in a practical way. Most chapters also include a theoretical introduction that will sharpen your understanding of the subject matter and invite you to go further. The book familiarizes you with the most common data mining tools of R, such as k-means, hierarchical regression, linear regression, association rules, principal component analysis, multilevel modeling, k-NN, Naïve Bayes, decision trees, and text mining. It also provides a description of visualization techniques using the basic visualization tools of R as well as lattice for visualizing patterns in data organized in groups. This book is invaluable for anyone fascinated by the data mining opportunities offered by GNU R and its packages.
Table of Contents (23 chapters)
Learning Predictive Analytics with R
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Exercises and Solutions
Index

Formatting plots


Plots in R can be formatted in many ways. We have already seen some of them in this chapter. In this section, we briefly explore some of these options. Let's go back to the data frame containing the 1,000 roulette spins and examine the relationship between the position on the roulette and the number by color. On line 1, we call the plot function. On line 2, we specify the attributes to be plotted, and add a little jitter to the data, using the jitter() function, otherwise, many points will be stacked over each other. The factor argument of this function controls the amount of jittering. We also reduce the size of the dots, using the cex attribute (line 3). We then title our graph and axes (lines 4 to 6).

Finally, we want to color the dots according to whether the number drawn is red or not (line 7). For this purpose, we use the col attribute:

1    plot( 
2      jitter(Data$position, factor=4),jitter(Data$number, factor=4),
3      cex = 0.5,
4      main = "Relationship between...