ml_banner

Association Rules Mining / Market Basket Analysis

Co-occurrence grouping, also known as association discovery mining or market basket analysis, tries to find associations between entities based on transactions. If a customer bought product A, then association mining tries to predict which product B the customer will also buy from historical data.

There will undoubtedly be many such co-occurrences in an itemset, and one way to simplify the rules is to add a constraint called support. Support of the association means that such rules must apply to some minimum percentage of the data

Together with support, we also have another measure called confidence. Confidence can be seen as the strength of a rule. The probability that B occurs when A occurs
The final measure of association effectiveness is called lift. Lift measures how much more frequently associations occur than would be expected by chance.

Start by importing the necessary libraries.assoc_import_libraries

The example dataset that I will be using is market_example.csv

The next few lines of code will import the example dataset, create the market basket rules and export the file to excel

The next few lines of code will import the example dataset, create the market basket rules and export the file to excel.

assoc_code

Finally we have a subset of the association rules

assoc_excel