Market Basket Analysis and its implementation in retail stores:

Abhishek Dinavahi
3 min readSep 28, 2021

Did you ever go to a retail chain and wonder why in majority of layouts, beverages and chips are placed together? In fact there is an urban legend of Beer and Diaper which states that middle aged men who purchase diaper also pickup beer on their way home. But, how would one come to the conclusion that a set of categories are to be placed together for a better cross sale? Well, the solution to that is Market Basket Analysis.

What is Market Basket Analysis?

Market Basket Analysis or MBA in short is a technique that provides the association levels between different items an. It looks for combinations of items that occur together in transactions frequently and helps retailers identify trends or patterns.

For the tech geeks out there, it’s an “if statement”, where if purchase (milk) then purchase (bread). So MBA forms patterns between milk and biscuit and rates it on different attributes.

{Milk}->{Bread}

There are two main attributes/features in MBA.

Antecedent — The If part
Consequent — the Then part

How would I perform this analysis if my dataset is really huge?

Well, nothing to worry about. There are already models which will compute MBA for you without the need of putting in too much effort. The three main metrics on which MBA is calculated are

Support: It is the popularity of an item. Well, to put it in simpler terms, it is the ratio of transactions involving an item to the entire transaction count

Ex: Let us say you have bought five packets of Lays Magic masala chips packet and have bought 30 different items. Support for the Lays packet would be 5/30 = 0.16

Confidence: Likelihood that customer who bought both P1 and P2. Confidence divides the number of transactions involving both the products by the transactions involving only one product. This will help us determine which product is influencing the purchase of which product.

Ex: Confidence (Lays->Coca Cola) = (Transactions involving both Lays and Coke)/Transactions involving only Lays

In our case, let us assume that we have purchased 6 Lays and 2 Cokes.

Confidence(Lays->Coca Cola) = (2/30)/(6/30) = 0.33

Lift: Helps us in determining increase in sale of P1 when we sell to P2.
Lift(A => B) = Confidence(A, B) / Support(B)

Lift can be interpreted as follows:

Lift Values and Interpretation

Do I have to code for getting my MBA?

Well not really. You can perform your MBA in coding language of your choice, but incase you are a non-coding business analyst, you have a variety of tools that help you perform the same analysis.

Alteryx has dedicated tools for performing MBA

Market Basket Analysis results

Alteryx provides us the flexibility of choosing different algorithms for MBA like Apriori and ECLAT with multiple configurations for parameter tuning for the most optimized results.

Any thoughts on how else MBA can be used? Please list it down in the comments.

--

--