Visualizing metrics

Market Basket Analysis in R

Christopher Bruffaerts

Statistician

Interactive table with metrics

Rules from Grocery store

library(arules)
rules = apriori(data_trx, 
                parameter = list(
                  supp = 3/7, conf=0.6, minlen=2)
                )
inspect(rules)

Interactive table

library(arulesViz)
inspectDT(rules)

HTML table

inspect_DT_rule

Market Basket Analysis in R

Scatter plots introduction

Inspection of the rules

inspect(rules)
    lhs         rhs      support   confidence lift      count
[1] {Bread}  => {Butter} 0.4285714 1.0000000  1.1666667 3    
[2] {Cheese} => {Wine}   0.4285714 0.7500000  1.0500000 3    
[3] {Wine}   => {Cheese} 0.4285714 0.6000000  1.0500000 3    
[4] {Cheese} => {Butter} 0.4285714 0.7500000  0.8750000 3    
[5] {Wine}   => {Butter} 0.5714286 0.8000000  0.9333333 4    
[6] {Butter} => {Wine}   0.5714286 0.6666667  0.9333333 4

Scatterplot from arulesViz

plot(rules)

scatter_grocery

Market Basket Analysis in R

Flexible arules plots

Options of the plot

plot(rulesObject, measure, shading, method)
  • rulesObject: the rules object to be plotted
  • measure: Measures for rule interestingness (Support, Confidence, lift,...)
  • shading: Measure used to color points.
  • method: Visualization method to be used ("scatterplot", "matrix", "two-key plot", "matrix3D")

Example

plot(rules, measure = c("confidence", "lift"),
     shading = "support",
     method = "scatterplot")

scatter_grocery_plot

Market Basket Analysis in R

Other arules plots

Two-key plot

plot(rules, method = "two-key plot")

two_key_plot

Market Basket Analysis in R

Jittering your plots

No jittering

plot(rules, method = "two-key plot")

two_key_plot

With jittering

plot(rules, method = "two-key plot",jitter = 2)

two_key_plot_jitter

Market Basket Analysis in R

Interactive arules plots

Interactive rules

plot(rules, engine = "plotly")

From static to interactive

rules_plotly

Market Basket Analysis in R

Let's visualize metrics!

Market Basket Analysis in R

Preparing Video For Download...