Visualizing transactions and rules

Market Basket Analysis in R

Christopher Bruffaerts

Statistician

Interactive inspection

Rule extraction

rules = apriori(Groceries, 
                parameter = list(
                  supp=.001,
                  conf=.5,
                  minlen=2,
                  target='rules'
                 ))
# Datatable inspection
inspectDT(rules)

HTML table

DT_groceries

Market Basket Analysis in R

Interactive scatterplots

Plot from arulesViz

# Plot rules as scatterplot
plot(rules, method = "scatterplot",
     engine = "html")

Other types of plots using method:

  • two-key plot
  • grouped
  • matrix

Scatterplots and others

Groceries_interactive_scatter

Market Basket Analysis in R

Interactive graphs

The engine and the method

# Plot rules as graph
plot(rules, method = "graph",
     engine = "html")

graph_groceries

Market Basket Analysis in R

Interactive subgraphs

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")

subgraph_groceries

Market Basket Analysis in R

RuleExploring Groceries

rules = apriori(Groceries, parameter=list(supp=0.001, conf=0.8))
ruleExplorer(rules)

shiny_groceries

Market Basket Analysis in R

Let's visualize some movie rules!

Market Basket Analysis in R

Preparing Video For Download...