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

Filtering a large number of rules

Once we have the rules built, we can use special subsetting functions to filter items from itemsets on either the left (lhs) or right (rhs) side of the association rule. This is valuable if you are looking for particular items within the itemsets.

Use the %in% operator to perform an exact match, or %pin% to perform a partial match:

# to see what 'Christmas' purchases imply. lhs.rules <- subset(rulesx, subset = lhs %pin% "CHRISTMAS") lhs.rules 
> set of 44 rules 
inspect(lhs.rules) 
 >     lhs                   rhs       support    confidence lift     > 4   {CHRISTMAS}        => {COVER}   0.02063597 0.1292548  1.500480 > 26  {CHRISTMAS}        => {CANDLES} 0.02702504 0.1692732  1.481358 > 47  {CHRISTMAS}        => {MUG}     0.02379379 0.1490340  1.060845 > 49 {CHRISTMAS} => {BOWL} ...

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