Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # We can see, based on the brightest red entries, that highest lift occurs with the least confidence and support.
- plot(rules@quality)
- # We can see that lift is proportional to confidence in our linear groupings. This relationship is significant and worthy of further analysis.
- slope <- sort(round(rules@quality$lift / rules@quality$confidence, 2))
- # Display the number of times each slope appears in the dataset.
- unlist(lapply(split(slope,f=slope), length))
- # Using inspect() can provide us with more concise information to review.
- inspect(head(sort(rules, by="lift"), 10))
- # While these are interesting, our confidence threshold could be higher.
- confidentRules <- rules[quality(rules)$confidence > 0.9]
- confidentRules
- set of 127 rules
- # This provides us with 127 rules, down from the previously 2918, that we can have a high level of confidence in. Let's get a visual.
- plot(confidentRules, method="matrix", measure=c("lift", "confidence"), control=list(reorder=TRUE))
- # This is a comprehensive graph that indicates how antecedent items can lead to consequent items; however, another visualization may offer "friendlier" insights.
- highLiftRules <- head(sort(rules, by="lift"), 5)
- plot(highLiftRules, method="graph", control=list(type="items"))
- #############################################################################################
- # CONCLUSION
- #############################################################################################
- # By using lift and leverage, we have discovered rules of interest that are not coincidental.
- # The meaningfulness of certain discoveries may depend on the business case. We would create
- # a kit of items based around frequent itemsets.
- inspect(head(sort(rules, by="lift"), 10))
- lhs rhs support confidence lift
- [1] {Instant food products,soda} => {hamburger meat} 0.001220132 0.6315789 18.995654
- [2] {soda,popcorn} => {salty snack} 0.001220132 0.6315789 16.697793
- [3] {ham,processed cheese} => {white bread} 0.001931876 0.6333333 15.045491
- [4] {tropical fruit,other vegetables,yogurt,white bread} => {butter} 0.001016777 0.6666667 12.030581
- [5] {hamburger meat,yogurt,whipped/sour cream} => {butter} 0.001016777 0.6250000 11.278670
- [6] {tropical fruit,other vegetables,whole milk,yogurt,domestic eggs} => {butter} 0.001016777 0.6250000 11.278670
- [7] {liquor,red/blush wine} => {bottled beer} 0.001931876 0.9047619 11.235269
- [8] {other vegetables,butter,sugar} => {whipped/sour cream} 0.001016777 0.7142857 9.964539
- [9] {whole milk,butter,hard cheese} => {whipped/sour cream} 0.001423488 0.6666667 9.300236
- [10] {tropical fruit,other vegetables,butter,fruit/vegetable juice} => {whipped/sour cream} 0.001016777 0.6666667 9.300236
Add Comment
Please, Sign In to add comment