Market Basket Analysis in R
Christopher Bruffaerts
Statistician
Rule extraction
rules = apriori(Groceries,
parameter = list(
supp=.001,
conf=.5,
minlen=2,
target='rules'
))
# Datatable inspection
inspectDT(rules)
HTML table
Plot from arulesViz
# Plot rules as scatterplot
plot(rules, method = "scatterplot",
engine = "html")
Other types of plots using method
:
Scatterplots and others
The engine and the method
# Plot rules as graph
plot(rules, method = "graph",
engine = "html")
Sorting extracted rules
# Top 10 rules with highest confidence
top10_rules_Groceries =
head(sort(rules,by = "confidence"), 10)
inspect(top10_rules_Groceries)
# Plot the top 10 rules
plot(top10_rules_Groceries,
method = "graph", engine = "html")
rules = apriori(Groceries, parameter=list(supp=0.001, conf=0.8))
ruleExplorer(rules)
Market Basket Analysis in R