Database Reference
In-Depth Information
5.5 An Example: Transactions in a Grocery Store
An example illustrates the application of the Apriori algorithm to a relatively simple
case that generalizes to those used in practice. Using R and the arules and
arulesViz packages, this example shows how to use the Apriori algorithm to
generate frequent itemsets and rules and to evaluate and visualize the rules.
The following commands install these two packages and import them into the
current R workspace:
install.packages('arules')
install.packages('arulesViz')
library('arules')
library('arulesViz')
5.5.1 The Groceries Dataset
The example uses the Groceries dataset from the R arules package. The
Groceries dataset is collected from 30 days of real-world point-of-sale
transactions of a grocery store. The dataset contains 9,835 transactions, and the
items are aggregated into 169 categories.
data(Groceries)
Groceries
transactions in sparse format with
9835 transactions (rows) and
169 items (columns)
The summary shows that the most frequent items in the dataset include items
such as whole milk, other vegetables, rolls/buns, soda, and yogurt. These items are
purchased more often than the others.
summary(Groceries)
transactions as itemMatrix in sparse format with
9835 rows (elements/itemsets/transactions) and
169 columns (items) and a density of 0.02609146
most frequent items:
whole milk other vegetables rolls/buns soda
2513 1903 1809 1715
Search WWH ::




Custom Search