Perform the following steps to visualize the association rule:
- First, you need to install and load the arulesViz package:
> install.packages("arulesViz") > library(arulesViz)
- You can then make a scatter plot from the pruned rules:
> plot(rules.pruned)
The scatter plot of pruned association rules
- 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
- 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"))
- 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
- Also, the association rules can be visualized in a balloon plot:
> plot(soda_rule, method="grouped")
Balloon plot of association rules