Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. # We can see, based on the brightest red entries, that highest lift occurs with the least confidence and support.
  2.  
  3. plot(rules@quality)
  4.  
  5. # We can see that lift is proportional to confidence in our linear groupings. This relationship is significant and worthy of further analysis.
  6.  
  7. slope <- sort(round(rules@quality$lift / rules@quality$confidence, 2))
  8.  
  9. # Display the number of times each slope appears in the dataset.
  10.  
  11. unlist(lapply(split(slope,f=slope), length))
  12.  
  13. # Using inspect() can provide us with more concise information to review.
  14.  
  15. inspect(head(sort(rules, by="lift"), 10))
  16.  
  17. # While these are interesting, our confidence threshold could be higher.
  18.  
  19. confidentRules <- rules[quality(rules)$confidence > 0.9]
  20. confidentRules
  21.  
  22. set of 127 rules
  23.  
  24. # 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.
  25.  
  26. plot(confidentRules, method="matrix", measure=c("lift", "confidence"), control=list(reorder=TRUE))
  27.  
  28. # This is a comprehensive graph that indicates how antecedent items can lead to consequent items; however, another visualization may offer "friendlier" insights.
  29.  
  30. highLiftRules <- head(sort(rules, by="lift"), 5)
  31. plot(highLiftRules, method="graph", control=list(type="items"))
  32. #############################################################################################
  33. # CONCLUSION
  34. #############################################################################################
  35. # By using lift and leverage, we have discovered rules of interest that are not coincidental.
  36. # The meaningfulness of certain discoveries may depend on the business case. We would create
  37. # a kit of items based around frequent itemsets.
  38.  
  39. inspect(head(sort(rules, by="lift"), 10))
  40.  
  41. lhs rhs support confidence lift
  42. [1] {Instant food products,soda} => {hamburger meat} 0.001220132 0.6315789 18.995654
  43. [2] {soda,popcorn} => {salty snack} 0.001220132 0.6315789 16.697793
  44. [3] {ham,processed cheese} => {white bread} 0.001931876 0.6333333 15.045491
  45. [4] {tropical fruit,other vegetables,yogurt,white bread} => {butter} 0.001016777 0.6666667 12.030581
  46. [5] {hamburger meat,yogurt,whipped/sour cream} => {butter} 0.001016777 0.6250000 11.278670
  47. [6] {tropical fruit,other vegetables,whole milk,yogurt,domestic eggs} => {butter} 0.001016777 0.6250000 11.278670
  48. [7] {liquor,red/blush wine} => {bottled beer} 0.001931876 0.9047619 11.235269
  49. [8] {other vegetables,butter,sugar} => {whipped/sour cream} 0.001016777 0.7142857 9.964539
  50. [9] {whole milk,butter,hard cheese} => {whipped/sour cream} 0.001423488 0.6666667 9.300236
  51. [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