O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating subsets of the rules

As we did before, we can look at some of the subsets by parsing the left or right side.

For example, we might be interested in seeing what items yielded purchasing chocolate things:

  • Subset the rules set using the %pin% operator (partial match), and look for any transactions where chocolate appears in the right-hand side:

        purchased.this <- "Chocolate"        lhs.rules <- subset(rules1, subset = rhs %pin%           purchased.this)
  • Printing lhs.rules shows that there are 487 of them:

        print(lhs.rules) > set of 487 rules
  • Sort them by lift, inspect them, and plot the first 15 as a graph:

lhs.rules <- sort(lhs.rules, by = "lift")inspect(head(sort(lhs.rules, by = "lift"))) > lhs rhs support confidence lift > 1 {CakeTowelSpots} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required