Loading...

Market basket analysis working example

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 IdCustomer IdProduct 1 nameProduct 2 nameProduct 1 categoryProduct 2 categoryProduct 1 labelProduct 2 labelFirst product total quantitySecond product total quantityProduct 1 revenueProduct 2 revenueTransaction revenue
1111Apple Fruits No discountNo discount2 100 100
2222ApplePotatoFruitsVegetables15% off 3215050350
3111Tshirts Clothing 30% off 3 450 450
4111AppleRoseFruitsFlowersComplementary 42200400600
5111ApplePotatoFruitsVegetables25% off 53250300550
6333PotatoTshirtsVegetablesClothing  1150150250
7333BananaSpinachFruitsVegetables  23100600700

MBA Analysis - Example 1

Report type : Transaction Level Analysis

Analysis by dimension : Product Name

Product 1 nameProduct 2 nameFirst Product Total QuantitySecond Product Total QuantityFirst Product Total Transaction CountSecond Product Total Transaction CountCombined Total CountFirst product total sales revenueSecond product total sales revenueCombined sales revenueFirst product sales revenue contributionSecond product sales revenue contributionSupportConfidenceLift
ApplePotato14643270060090040050028.57%50.00%1.75
AppleRose14241170040060020040014.29%25.00%1.75
PotatoTshirts6431160015025010015014.29%33.33%2.33
BananaSpinach2311110060070010060014.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 1Product category 2First product category total quantitySecond product category total quantityFirst product total transaction countSecond product total transaction CountCombined total countFirst product total sales revenueSecond product total sales revenueCombined sales revenueFirst product category sales revenue contributionSecond product category sales revenue contribution
AppleTshirts144421700600550100450
AppleRose142411700400500100400
ApplePotato146432700400900300600
TshirtsApple4142426007001350900450
TshirtsRose42211600400850450400
RoseApple214141400700650400250
RosePotato26131400400700400300
PotatoBanana62311400100200100100
PotatoSpinach63311400600700100600
TshirtsBanana42211600100250150100
TshirtsSpinach43211600600750150600
TshirtsPotato46231600400750450300

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 1Product Category 2First product category total quantitySecond product category total quantityFirst product category total transaction countSecond product category total transaction countCombined transaction total countFirst product category total sales revenueSecond product category total sales revenueCombined sales revenueFirst product category sales revenue contributionSecond product category sales revenue contribution
FruitsVegetables169533800120016005001100
FruitsFlowers162511800400600200400
VegetablesClothing943211200600250100150

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.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation