How to do it...

Perform the following steps to visualize the association rule:

  1. First, you need to install and load the arulesViz package:
        > install.packages("arulesViz")
        > library(arulesViz)  
  1. You can then make a scatter plot from the pruned rules:
        > plot(rules.pruned)
The scatter plot of pruned association rules
  1. Additionally, to prevent overplotting, you can add jitter to the scatter plot:
        > plot(rules.pruned, shading="order", control=list(jitter=6))
The scatter plot of pruned association rules with jitters
  1. We then produce new rules with soda on the left-hand side using the Apriori algorithm:
        > soda_rule=apriori(data=Groceries, parameter=list(supp=0.001,conf
= 0.1, minlen=2), appearance = list(default="rhs",lhs="soda"))
  1. Next, you can plot soda_rule in a graph plot:
        > plot(sort(soda_rule, by="lift"), method="graph",
control=list(type="items"))
Graph plot of association rules
  1. Also, the association rules can be visualized in a balloon plot:
        > plot(soda_rule, method="grouped")  
Balloon plot of association rules
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset