Introduction to Market Basket Analysis

What is Market Basket Analysis?

  1. Identify products frequently purchased together.
    1. Biography and history
    2. Fiction and poetry
  2. Construct recommendations based on these findings.
    1. Place biography and history sections together
    2. Keep fiction and history apart

The Use Cases of Market Basket Analysis

  1. Build Netflix-style recommendations engine
  2. Improve product recommendations on an e-commerce store
  3. Cross-sell products in a retail setting
  4. Improve inventory management
  5. Upsell products

Association Rules

Generate Rules with itertools

from itertools import permutations 

# Extract unique items
flattened = [item for transaction in transactions for item in transaction
items = list(set(flattened))
# Compute and print rules
rules = list(permutations(items, 2)) 
print(rules) 

mlxtend Library