Skip to content

This first tutorial in marketing analysis with Python introduces Market Basket Analysis (MBA) , a powerful tool used for product promotion and recommendation.

License

Notifications You must be signed in to change notification settings

MKB-Datalab/marketing-analysis-part-1-market-basket-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📈 Marketing Analytics : Market Basket Analysis

Photo by Dave Goudreau on Unsplash

This repository opens a series of tutorials introducing techniques that will help you making better data-driven marketing decisions. We start by introducing Market Basket Analysis (MBA); a powerful tool used for product promotion and recommendation. We will discuss several techniques and show you their implementation such that you can employ them yourself.

Here we make use of Python tools. The main one is mlxtend package which is very useful for performing important tasks for Market Basket Analysis such as:

  1. Pre-process data
  2. Generate item sets and rules
  3. Filter according to metrics

After completing this tutorial, you'll know: What Market Basket Analysis is

  • How to prepare your data to apply MBA
  • Some metrics used in MBA
  • How to perform MBA using the Apriori algorithm
  • How to apply some simple visualizations used in MBA

The notebook Introduction to Market Basket Analysis provides an introduction to MBA through use cases.

📁 Data

In this tutorial we use two datasets.

  1. An small fictional bakery dataset consisting of 298 transactions containing 7 unique items.

  2. A transactional dataset which contains all the transactions occurring between 01/12/2010 and 09/12/2011 for a UK-based and registered online retail. This one is available at the UCI Machine Learning repository. Here we used a subset of the dataset containing only transactions of customers in The Netherlands.

Both datasets can be found here.

If you are curious to know we obtained the dataset containing only products purchased in The Netherlands was obtained check this notebook.

🔧 Tools

mlxtend Python package which contains useful tools for performing important tasks inherent to MBA.

In particular the following functions were used:

  • Transaction encoder (from mlxtend.preprocessing import TransactionEncoder)

  • Apriori algorithm (from mlxtend.frequent_patterns import apriori)

  • Association rule (from mlxtend.frequent_patterns import association_rules)

💻 Install requirements

  • Install requirements using pip install -r time_series_requirements.txt.
    • Make sure you use Python 3.
    • You may want to use a virtual environment for this.

◀️ Back to repository main page

About

This first tutorial in marketing analysis with Python introduces Market Basket Analysis (MBA) , a powerful tool used for product promotion and recommendation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published