Mining associations with the Apriori rule

Association mining is a technique that can discover interesting relationships hidden in a transaction dataset. This approach first finds all frequent itemsets and generates strong association rules from frequent itemsets. In this recipe, we will introduce how to perform association analysis using the Apriori rule.

Getting ready

Ensure you have completed the previous recipe by generating transactions and storing these in a variable, trans.

How to do it…

Please perform the following steps to analyze association rules:

  1. Use apriori to discover rules with support over 0.001 and confidence over 0.1:
    > rules <- apriori(trans, parameter = list(supp = 0.001, conf = 0.1, target= "rules"))
    > summary(rules)
    set of 6 rules ...

Get R for Data Science Cookbook 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.