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} ...

Get Practical Predictive Analytics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.