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

Discovering multipanel conditioning with xyplot()


The first thing we will do next is to check that lattice works properly. For this example, we will use the iris dataset. The iris dataset is one of the best known in data science. It is composed of four numeric attributes Sepal.Length, Sepal.Width, Petal.Length and Petal.Width which are measures of iris plants, as well as a factor, or nominal attribute Species which describes the membership of the plants to 3 different iris species: Virginica, Setosa and Versicolor. The data set is composed of 150 observations.

Doing this first plot will also allow us to discover the formula syntax used in most plots with lattice:

xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris)

In this line of code, we have used the xyplot() function to visualize the relationship between the sepal length and the sepal width of iris flowers conditioning on Species. This means that one scatterplot is produced for each of the groups. The function xyplot(), as well as...