Presentation is loading. Please wait.

Presentation is loading. Please wait.

Association Rules Lab.

Similar presentations


Presentation on theme: "Association Rules Lab."— Presentation transcript:

1 Association Rules Lab

2 Check R packages from RStudio
Are arules and arulesViz available? Loaded? These packages should ALREADY be installed! Search the User Library click on the box for arules to load click on the box for arulesViz to load

3 Available data in arules package: Epub and Groceries
Start with Groceries > data("Groceries") Inspect Groceries > Groceries

4 Try again with less data
Get summary > summary(Groceries) Visualize data > image(Groceries) Try again with less data > image(Groceries[1:200,]) Observations?

5 Find association rules How many rules did this produce?
rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.5)) How many rules did this produce? Inspect the rules > inspect(rules) Visualize the rules > plot(rules) Visualize length of rules > plot(rules, shading="order", control=list(main = "Two-key plot"))

6 What is the defn of Confidence
What is the defn of Confidence? Confidence(X -> Y): The % of transactions that contain X, which also contain Y What is the defn of Lift?

7 How can we focus on fewer better rules? Fewer, but not better
> inspect(rules[1:20] Sort by lift > inspect(head(sort(rules, by ="lift"),5)) Alternatively, be more restrictive > rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.8))

8 Which has more lift: dark or light spots? Try fewer rules
Examine grouped rules > plot(head(sort(rules, by ="lift"),500), method="grouped") Which has more lift: dark or light spots? Try fewer rules > plot(head(sort(rules, by ="lift"),50), method="grouped")

9 Try again with less data
Load in Epub data >data(Epub) Inspect Epub > Epub Get summary >summary(Epub) Visualize data > image(Epub) Try again with less data > image(Epub[1:1000,])

10 How many rules? (Obviously, defaults parameters are not good here.)
Build rules rules2 <- apriori(Epub) How many rules? (Obviously, defaults parameters are not good here.) Specify support and confidence thresholds rules2 <- apriori(Epub, parameter=list(support=0.001, confidence=0.5)) Can we be even more restrictive? rules3 <- apriori(Epub, parameter=list(support=0.01, confidence=0.5))

11 Inspect the rules Sort by lift Plot the rules Try Two-Key plot
> inspect(rules2) Sort by lift > inspect(head(sort(rules2,by="lift"),10)) Plot the rules > plot(rules2) Try Two-Key plot > plot(rules2, shading="order", control=list(main = "Two-key plot")) Does a group plot make sense? > plot(head(sort(rules2, by ="lift"),50), method="grouped")

12 For further visualization approaches supported by arulesViz see:


Download ppt "Association Rules Lab."

Similar presentations


Ads by Google