Market Basket Analysis

You might also like

You are on page 1of 30

MRA Projects

Market Basket Analysis


Presented By
Smita Patil
Problem Statement
A Grocery Store shared the transactional data with you. Your job is to identify the most popular combos that can be suggested to the
Grocery Store chain after a thorough analysis of the most commonly occurring sets of items in the customer orders. The Store doesn’t
have any combo offers.

Can you suggest the best combos & offers?

● Exploratory Data Analysis


● Use of Market Basket Analysis(Association Rule)
● Associations Identified
● A suggestion of possible combo with Lucrative Offers.
● Tool Used:python & Tableau
Exploratory Data Analysis
Data overview

● There are 20,641 rows and 3 columns in the grocery dataset.


● There are no missing value in data
● There are about 4330 duplicate rows in data which are dropped.
● There are 1139 Unique Transactions and 37 Unique Products.
● The data is for 3 years 2018,2019 and 2020.
● The data is for 9 months of 2018 and 2019 but only 2 months for 2020.
● The start date is 1st Jan 2018 and End date is 26th Fec 2020.
Order Count Trend w.r.t Date

● Data set has seasonality as purchase is high


for couple of months .

● No Data Points from October till December for


both
2018,2019.

● And only 2 months data is available for the year


2020
No of Items purchased(visits) and times item sold?

Maximum Basket size


contains 34 items and
minimum only 3 items.

Maximum no. sales was


640 while min sales 502
Top Customers who brought most purchase items

Top 5 customers
order Id who are
purchasing
frequently
1013,226,1071,97
5,1105.
Product-Wise Distribution

Poultry is the most frequently ordered item


followed by Soda and Ice-Cream.
Monthly -Yearly Order Counts

May 2018 and May 2019 having


almost same count of orders (67,66)

Feb 2020 shows the lowest counts of


order

May be as due to we have data


available till 26th Feb 2020.
Monthly Records

Number of Records are higher for


the month of January and February

May is the peak month for number


of orders if January and February
Are not considered.
Quarter-Wise % of Orders

1st quarter shows the highest % of orders


Yearly % of Orders

The Percentage of orders is


almost same for the year
2018(45.92%)
& 2019(45.22%)
Daily Orders Counts
Lowest value of (393) for 28th day of month.
Purchase is higher in the 1st week of month .
And purchase is higher for 17th days followed by 30th
day of months.
Week-Wise Order Counts

Monday is the lowest

Sunday and Friday are


almost similar.
Most Frequently Purchased Items
Least Purchased Items
Total items sold by Year

Year -wise highest sales is seen in


2018 followed by 2019 while 2020
sales is least
Total Number Of items sold by Months

Highest sales is for


March 2019 and least
sales is for Feb 2020
Total Number Of Items Sold by Week days
Total Number Of items sold by Days
Total Number Of Item Sold By Month

Sales is higher for


July month for
both 2018 and
2019
Market Basket Analysis
Market Basket Analysis
● Market Basket Analysis is a technique used by large retailers to uncover the
association between items or to identify relationship between items which are
brought together more frequently.
● Support :Measures how frequently the collection of items occurs together as
● A percentage of all transactions.
● Lift :Ratio of confidence to expected confidence.Higher the lift indicate higher
association between items.
● Confidence:The probability that a transaction contains the all the items in A and
also contains the items in B.
Packages used in Market Basket Analysis
● Python package used: Pandas
From mlxtend.frequent_patterns import apriori & association rules
● MLX tend apriori function helps to find out which items are frequently purchase together .
● Apriori function provides minimum level of support .
● Support: Percentage of time itemset appears in data set .
● For e.g. :if we set support =50% we will get only itemset that appears 50% of time in data .
● Mlxtend association rule function are used to build association rules.
● Set minimum thresholds for lift or confidence level.
● For e.g. if we set min threshold=1 ,we get rules wit 100% confidence .
● We get rules with different combinations .This information is used to build cross sell recommendation system .
● We recommend the combination as per those rules with higher confidence /lift value .Build strategies as discounts /coupons to
promote the items to grow sales.
MBA using Python
● Support Value set to 0.05 while the confidence is set to 0.60

● The rules generated are 37 in numbers.


● Sort the Rules by lift (Highest to Lowest)
Association Rule Learner Output

Sorted By Lift (Highest to Low)


Check for Rules with Lower Lift
Rules with items in antecedent and consequent are unlikely to brought
together.
The customer who purchase ice-
cream and coffee/Tea is unlikely to
buy laundry detergent as its lift is
only 0.84.

Similarly laundry detergent ,ice-


cream ,coffee/tea followed by
fruits,ice-creams and pork ,perk and
fruits ,ice-creams,and waffles
,poultry and tortillas.
Taking Top Rules w.r.t Lift >1.6 and confidence >0.66

Interpretations:

Rule 1 : Support says 5 % of customer who brought sandwich bags,cereals ,bagels and cheeses together.
Confidence is 67% who brought antecedents like sandwich bags,cereals ,bagels will also brought cheeses.
Lift is 1.72 .
Rule 2:Support says 5 % of customer who bought dinner rolls ,ice-creams ,spaghetti sauce and poultry
together.
Confidence is 69 % who brought antecedents like dinner rolls ,ice-creams ,bagels will also brought poultry.
Lift is 1.62 .
Recommendations
Combo offers:
1. Poultry with Eggs (Buy Poultry get a cartoon of egg free)
2. As per Rule 1 ,cheeses with Sandwich bags and Bangles can be combined at competitive price.
3. Combo offer of Poultry and Beef ,Spaghetti Sauce with Dinner Rolls and Poultry.
4. Lunch :Combo of Lunch Meat and Waffles with Juice .

Discounts Offers:
5. 10% off if you buy Poultry with One Egg Carton (Assuming 1 egg carton contains dozen
eggs )
6. 5% off on Cheese with Bagels
7. 15% off on Poultry & Beef if Brought together
8. 5% off on Milk and Ice-Cream if bought together
END

You might also like