Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Follow publication

Predicting purchases with Market Basket Analysis

Shashank Singh
Geek Culture
Published in
11 min readMay 26, 2021

Shopping Customers | Photo by Gustavo Fring from Pexels

Do you ever make impulse purchases? Sure you do. But, do you ever wonder why these products are so conveniently available to you even when you weren’t looking for them? All of us know about the Customers who bought this also bought section on Amazon, and the aforementioned impulse purchases happen there quite a lot.

What is Market Basket Analysis?

Some Terminologies

Items

Item set, I = {i₁,i₂,i₃, … ,iₙ}

Transactions

Transaction, tₙ = {iᵢ,iⱼ, … ,iₖ}

Rules

{i₁,i₂, … } ⇒ {iₖ}

Methodology

Association Rule Mining

Apriori Principle

Apriori Algorithm | Image by Author
Support(A ∪ B) = min(Support(A), Support(B))
Confidence(A => B) = P(B|A) = P(A ∩ B)/P(A)Confidence(A => B) = Support(A ∪ B)/Support(A)
Lift(A => B) = P(A ⋂ B)/[P(A) x P(B)]Lift(A => B) = Support(A ∪ B)/[Support(A) x Support(B)]Lift(A => B) = Confidence(A => B)/Support(B)

Goals of Association Rule Mining

Steps for Market Basket Analysis using Association Rules

Data

Dataset 1

“Online Retail”, contains all the transactions occurring between 01/12/2010 and 09/12/2011 for a UK-based and registered online retailer, taken from UCI Machine Learning Repository

Dataset 2

Groceries data from Department of Statistics and Biostatistics, California State University

Results

Dataset 1

Image by Author
Image by Author
Image by Author
Image by Author
Image by Author
Image by Author
Image by Author
Image by Author

Dataset 2

Image by Author
Image by Author
Image by Author
Image by Author
Image by Author

Final Words

Market basket analysis with the help of association rules can easily tell the customer buying behavior; and the retailer with the help of these concepts can easily setup his retail shop accordingly to expand the business in future.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Shashank Singh
Shashank Singh

Written by Shashank Singh

An undergrad student with an overdose of euphoria.

Responses (2)

Write a response