The following example explains the market basket analysis of a test dataset.
Raw dataset
The following is a test dataset that considers the edge cases, and is exhaustive to capture all nuances. The dataset contains 7 transactions across 3 different customers. Some transactions have only one product while some transactions have multiple products.
Raw data (Transactions) | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Transaction Id | Customer Id | Product 1 name | Product 2 name | Product 1 category | Product 2 category | Product 1 label | Product 2 label | First product total quantity | Second product total quantity | Product 1 revenue | Product 2 revenue | Transaction revenue |
1 | 111 | Apple | Fruits | No discount | No discount | 2 | 100 | 100 | ||||
2 | 222 | Apple | Potato | Fruits | Vegetables | 15% off | 3 | 2 | 150 | 50 | 350 | |
3 | 111 | Tshirts | Clothing | 30% off | 3 | 450 | 450 | |||||
4 | 111 | Apple | Rose | Fruits | Flowers | Complementary | 4 | 2 | 200 | 400 | 600 | |
5 | 111 | Apple | Potato | Fruits | Vegetables | 25% off | 5 | 3 | 250 | 300 | 550 | |
6 | 333 | Potato | Tshirts | Vegetables | Clothing | 1 | 1 | 50 | 150 | 250 | ||
7 | 333 | Banana | Spinach | Fruits | Vegetables | 2 | 3 | 100 | 600 | 700 |
MBA Analysis - Example 1
Report type : Transaction Level Analysis
Analysis by dimension : Product Name
Product 1 name | Product 2 name | First Product Total Quantity | Second Product Total Quantity | First Product Total Transaction Count | Second Product Total Transaction Count | Combined Total Count | First product total sales revenue | Second product total sales revenue | Combined sales revenue | First product sales revenue contribution | Second product sales revenue contribution | Support | Confidence | Lift |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Apple | Potato | 14 | 6 | 4 | 3 | 2 | 700 | 600 | 900 | 400 | 500 | 28.57% | 50.00% | 1.75 |
Apple | Rose | 14 | 2 | 4 | 1 | 1 | 700 | 400 | 600 | 200 | 400 | 14.29% | 25.00% | 1.75 |
Potato | Tshirts | 6 | 4 | 3 | 1 | 1 | 600 | 150 | 250 | 100 | 150 | 14.29% | 33.33% | 2.33 |
Banana | Spinach | 2 | 3 | 1 | 1 | 1 | 100 | 600 | 700 | 100 | 600 | 14.29% | 100.00% | 7.00 |
The following is the detailed analysis:
First and second product total quantity is the aggregation of the product quantity across all transactions. Product total quantity specifies the quantity of individual products sold. 14 units of Apple are bought.
Similarly, the first and second product total transaction count is the aggregation of the transaction count. Apple appeared in 4 transactions.
First and second product total sales revenue is the aggregation of sales revenue. The revenue from Potato is $600.
Combined sales revenue is the revenue generated when both products were bought together in a transaction. Therefore, of the 7 transactions, Apple and Potato were bought together in two transactions generating a $900 revenue.
Support is the ratio of ‘combined total transaction count’ and ‘total transactions’. Here, Support for Apple and Potato is ‘2 combined transactions/7 total transactions = 28.57%’.
Confidence is the ratio of how frequently the second product was bought with the first product. Here, Confidence of Potato given that Apple was bought is ‘2 combined transactions/4 total transactions of Apple = 50%’.
A Lift score of higher than 1 indicates a strong correlation between the first and second product.
MBA Analysis - Example 2
Report type : Customer Level Analysis
Analysis by dimension : Product Name
Product category 1 | Product category 2 | First product category total quantity | Second product category total quantity | First product total transaction count | Second product total transaction Count | Combined total count | First product total sales revenue | Second product total sales revenue | Combined sales revenue | First product category sales revenue contribution | Second product category sales revenue contribution |
---|---|---|---|---|---|---|---|---|---|---|---|
Apple | Tshirts | 14 | 4 | 4 | 2 | 1 | 700 | 600 | 550 | 100 | 450 |
Apple | Rose | 14 | 2 | 4 | 1 | 1 | 700 | 400 | 500 | 100 | 400 |
Apple | Potato | 14 | 6 | 4 | 3 | 2 | 700 | 400 | 900 | 300 | 600 |
Tshirts | Apple | 4 | 14 | 2 | 4 | 2 | 600 | 700 | 1350 | 900 | 450 |
Tshirts | Rose | 4 | 2 | 2 | 1 | 1 | 600 | 400 | 850 | 450 | 400 |
Rose | Apple | 2 | 14 | 1 | 4 | 1 | 400 | 700 | 650 | 400 | 250 |
Rose | Potato | 2 | 6 | 1 | 3 | 1 | 400 | 400 | 700 | 400 | 300 |
Potato | Banana | 6 | 2 | 3 | 1 | 1 | 400 | 100 | 200 | 100 | 100 |
Potato | Spinach | 6 | 3 | 3 | 1 | 1 | 400 | 600 | 700 | 100 | 600 |
Tshirts | Banana | 4 | 2 | 2 | 1 | 1 | 600 | 100 | 250 | 150 | 100 |
Tshirts | Spinach | 4 | 3 | 2 | 1 | 1 | 600 | 600 | 750 | 150 | 600 |
Tshirts | Potato | 4 | 6 | 2 | 3 | 1 | 600 | 400 | 750 | 450 | 300 |
The following is the detailed analysis:
For customer level analysis, combinations or baskets are formed by considering subsequent transactions for a particular customer. For example, for customer id “111”, with transaction id “1”, the customer bought Apple. The next transaction of customer “111” was Tshirt with transaction id “3”. Thus, a valid basket in customer level analysis is Apple and Tshirt. Similarly, other valid combinations or baskets considering only customer id “111” can be:
(Apple and Rose) by combining transaction 1 and 4
(Apple and Potato) by combining transaction 1 and 5
Thus, Transaction Level Analysis focuses on intra-transactional combinations while Customer Level Analysis focuses on inter-transactional combinations.
MBA Analysis - Example 3
Report type : Transaction Level Analysis
Analysis by dimension : Product Category
Product Category 1 | Product Category 2 | First product category total quantity | Second product category total quantity | First product category total transaction count | Second product category total transaction count | Combined transaction total count | First product category total sales revenue | Second product category total sales revenue | Combined sales revenue | First product category sales revenue contribution | Second product category sales revenue contribution |
---|---|---|---|---|---|---|---|---|---|---|---|
Fruits | Vegetables | 16 | 9 | 5 | 3 | 3 | 800 | 1200 | 1600 | 500 | 1100 |
Fruits | Flowers | 16 | 2 | 5 | 1 | 1 | 800 | 400 | 600 | 200 | 400 |
Vegetables | Clothing | 9 | 4 | 3 | 2 | 1 | 1200 | 600 | 250 | 100 | 150 |
The following is the detailed analysis:
The aggregation of baskets is done by Product Category.
This example explains that out of 7 transactions, Fruits and Vegetables were bought together in 3 transactions, generating a revenue of $1600, which is approximately 57% of the total revenue.