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

Analyzing data with apriori in R


In this section, we will continue with another supermarket example and analyze associations in the Groceries dataset. In order to use this dataset and to explore association rules in R, we need to install and load the arules package:

install.packages("arules")
library(arules)
data(Groceries)

Using apriori for basic analysis

We can now explore relationships between purchased products in this dataset. This dataset is already in a form exploitable by apriori (transactions). We will first use the default parameters as follows:

rules = apriori(Groceries)

The output is provided in the following screenshot:

Running apriori on the Groceries dataset with default parameters

We can see on the first line the parameters used in the analysis—in this case, the default. Around the middle of the output (where the arrow is), we see that there are 169 items in 9835 transactions in this dataset, and that 0 rules have been found (see second to last line). If you try this with your own...