Market Basket Analysis Leveraging Machine Learning: Friday Fun

In this week’s Tuesday Tutorial episode (below), we covered Market Basket Analysis. In today’s episode of Friday Fun, we will explore a use case for the same. The video of the Friday Fun episode can be found at the end of this article.This blog post contains the data file and the code notebook for our use case.

Our client is an online E-commerce company that wants you to help them develop a market basket-based product recommendation system (“Customer who bought these items also typically bought”). They have provided you the dataset below for your analysis:

The Online Retail II data set, which includes the company’s online sales, contains sales data between 01/12/2009 and 09/12/2011. The variables within the dataset are:

  • InvoiceNo: Invoice Number, which essentially represents a transaction
  • StockCode: Product Code, which is a unique number for each product
  • Description: Product description
  • Quantity: Number of products: how many of the products on the invoices were sold.
  • InvoiceDate
  • Unit Price
  • CustomerID: Unique customer number
  • Country

We will leverage the following high level steps to develop the recommendation algorithm for our client:

  • Step 1: Import Data & Data Preprocessing
  • Step 2: Preparing Invoice-Product Matrix fot ARL Data Structure
  • Step 3: Determination of Association Rules
  • Step 4: Suggesting appropriate product offers to customers at the basket stage

The code notebook for the analysis is below. Please note that you do not need this to understand the use case, as we will explore it in simple English. However, it has been provided, along with the dataset, for those who would like to play around and be nerdy.

If you want to put a solution like this into production, there will obviously be some next steps. Each product and related products will have to be stored at the database level and will need to be integrated with the online purchasing processes. When a customer is purchasing product A, the first 3 products related to this product can be recommended as “Customer who bought these items also typically bought”, as shown in the screen grab below.

The full episode of Friday Fun can be watched here:

https://vimeo.com/926476201


Leave a comment