8. Market Basket Analysis
Activity 8.01: Loading and Preparing Full Online Retail Data
Solution:
- Import the required libraries:
import matplotlib.pyplot as plt import mlxtend.frequent_patterns import mlxtend.preprocessing import numpy import pandas
- Load the online retail dataset file:
online = pandas.read_excel(io="./Online Retail.xlsx", \ sheet_name="Online Retail", \ header=0)
- Clean and prep the data for modeling, including turning the cleaned data into a list of lists:
online['IsCPresent'] = (online['InvoiceNo'].astype(str)\ ...