Icon

Finding Association Rules for Market Basket Analysis

There has been no title set for this workflow's metadata.

This workflow builds a recommendation engine for market basket analysis using the Borgelt version of the Apriori algorithm. A market basket analysis aims to analyze whether combinations of products frequently co-occur in transactions.

URL: Market Basket Analysis and Recommendation Engines https://www.knime.org/blog/market-basket-analysis-and-recommendation-engines
URL: Recommendation Engines https://youtu.be/z8jbAm38yXs

Finding Association Rules for Market Basket Analysis

The aim of a market basket analysis is to analyze whether there are combinations of products that frequently co-occur in transactions. This workflow illustrates how to build a recommendation engine for market basket analysis.


Task

Build a recommendation engine for market basket analysis using the Borgelt version of the Apriori algorithm.

Data Reading

2 files:

  • Transactions

  • Products info

Transactions are in the shape of concatenated Strings. The Association Rule learner node requires a collection of items as input. The Cell Splitter node here transforms string rows into item collections.

Another way of getting item collections is to use the aggregation method "List" in a GroupBy node.

Both files are located in TheData/Baskets


Build Association Rules

The Association Rule Learner (Borgelt) node implements the "A priori" algorithm to find the association rules.

  • min. set size = 1

  • min rule confidence = 10%

  • min support (in %) is controlled by the Double Configuration node

Data Processing


  • Create RuleID from RowID

  • Ungroup antecedent item collection

  • Join prices and product names to antecedent items

  • Join consequent item to product name

  • Add price to consequent item

  • Calculate price stats and rule revenue

Save the Model

The model here is a table of rules.

We write the association rules to a file.

Reading "items.table": ID, price, productName
Table Reader
Ungroup collections
Convert Item ID to String
Number To String
Min. set size = 1 min rule confidence = 10% min support is controlled by Double Input Quickform node in %
Association Rule Learner (Borgelt)
Min support = 2.5
Double Configuration
Transform string rowsinto item collections
Cell Splitter
Reading"transactions.table":1 row = 1 transactionproduct IDs bought for each transaction
Table Reader
Write association rules to a file
Table Writer

Nodes

Extensions

Links