Book Image

Mastering Machine Learning with R

By : Cory Lesmeister
Book Image

Mastering Machine Learning with R

By: Cory Lesmeister

Overview of this book

Table of Contents (20 chapters)
Mastering Machine Learning with R
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data understanding and preparation


For this analysis, we will only need to load two packages as well as the Groceries dataset:

> library(arules)

> library(arulesViz)

> data(Groceries)
> head(Groceries)
> str(Groceries)
> Groceries
transactions in sparse format with
 9835 transactions (rows) and
 169 items (columns)

This dataset is structured as a sparse matrix object known as the class of transaction.

So, once the structure is that of the class transaction, our standard exploration techniques will not work, but the arules package offers us other techniques to explore the data. On a side note, if you have a data frame or matrix and want to convert it to the transaction class, you can do this with a simple syntax using the as() function. The following code is for illustrative purposes only, so do not run it:

> transaction.class.name = as(current.data.frame,"transactions")

The best way to explore this data is with an item frequency plot using the itemFrequencyPlot() function...