Market Basket Analysis is a technique used in data mining and machine learning to understand associations between products or items in a dataset. The aim of this analysis is to understand which items are frequently purchased together by customers or in general, and this knowledge can be used for marketing campaign, stocking and inventory management and can help the business to make informed decisions. It is a powerful tool which is widely used in the retail industry.
In this tutorial, we will be using Orange Data Mining Tools to perform Market Basket Analysis on a sample transaction data. Before we proceed with the actual analysis, let's have a quick overview of Orange Data Mining Tool.
Orange is an open-source data visualization and analysis toolkit developed in Python. Orange provides a graphical user interface for experimenting with machine learning and data mining algorithms, including Market Basket Analysis. Orange is easy to use and has a low learning curve. With Orange, users can visually inspect the data and model, select the right algorithms, perform analysis, and get an immediate insight into the results.
Now, let's get started with the Market Basket Analysis in Orange.
Step 1: Install Orange Data Mining Tool
The first step is to install the Orange Data Mining Tool. You can download the tool from the Orange website (https://orange.biolab.si/) and install it on your system.
Step 2: Gather Data
For this demo, we will use a simulated dataset that contains transaction data of items purchased by customers. It is a comma-separated file (csv) and has eight columns, including customer ID, date of purchase, and five product categories.
Let’s have a look at the data by importing it in Orange.
[image: alt text] open
Step 3: Import Data in Orange
We will now import the data into Orange. To import the file, follow the below steps:
- Open Orange data mining tool and select the data tab
- Click "browse file" and select the csv file
- Make sure that the data separator is correct
- Click import button
Now you can see the data in the data tab.
[image: alt text] open
Step 4: Perform Market Basket Analysis
To perform Market Basket Analysis, follow these steps:
- Select the "Market Basket Analysis" node from the toolbox and drag it to the workflow canvas.
- Connect the "File" node to the "Market Basket Analysis" node.
- Double-click the "Market Basket Analysis" node to open the widget.
[image: alt text] open
There are two options to select before running the analysis – selecting the data and adjusting support and confidence settings:
Data Setting:
In the data setting tab, select the itemset and transaction identifier. In our case, the product column in the dataset is our itemset.
[image: alt text] open
Algorithm Setting:
In algorithm setting tab, set the values for support and confidence. The minimum support is the percentage of transactions that contain the itemset, and the minimum confidence is the percentage of transactions containing item A also contain item B. In our experiment, we set the support to 10% and confidence to 60%.
After setting the data and the algorithms, click the "Apply" button.
[image: alt text] open
Once you click on the 'Apply' button, the Market Basket Analysis node will run, and you will see the results in the right pane as shown below:
[image: alt text] open
The results show the frequent itemsets, which are the pairs or groups of items that were frequently purchased together by the customers. The analysis has identified six frequent itemsets in the dataset.
Step 5: Interpret the Results
In the results tab, you can see the itemset, support, and confidence score.
For example, the itemset (Cocktail Shakers, Whiskey Glasses) have a support of 12.21%, which means that 12.21% of transactions contain the two items in combination. The confidence score of 69.14% indicates that if a customer bought a cocktail shaker, there is a 69.14% probability that they will also buy whiskey glasses in the same transaction.
Step 6: Test Your Understanding
Now that we have completed the Market Basket Analysis on the sample dataset, let's test your understanding of associativity rules.
Question: Given the below itemsets, can you interpret the meaning of support and confidence?
| Itemset | Support | Confidence |
|---|
| Tea, Sugar, Milk | 10% | 80% |
| Coffee, Sugar | 8% | 70% |
| Juice, Bread | 5% | 60% |
Answer:
The support is the percentage of transactions that contain the items in combination, and the confidence score is the percentage of transactions containing item A also contain item B.
-
For Itemset (Tea, Sugar, Milk), 10% of transactions include all three items. Additionally, when a customer buys Tea and milk, there is an 80% probability that he will also buy sugar in the same transaction.
-
For Itemset (Coffee, Sugar), 8% of transactions include coffee and sugar both. 70% of the customers who purchase coffee are also purchasing sugar in the same transaction.
-
For Itemset (Juice, Bread), 5% of transactions include both Juice and Bread. 60% of the customers who purchase juice also purchase bread in the same transaction.
Conclusion
Market Basket Analysis is an essential tool for retailers and businesses as it provides insights into the buying behavior of customers. With Orange data mining tool, it is straightforward to perform the analysis with its user-friendly environment. In this tutorial, we went through the steps required to perform Market Basket Analysis in Orange. By analyzing the results, businesses can improve their marketing strategy, manage inventory and stocking of items more efficiently, and increase sales revenue.