Reference no: EM132912231
Association Rule Learning
1.1 Loading and Transforming the "grocery transactions.txt" dataset
From vUWS, download the "grocery transactions.txt" dataset via:
Learning Modules → Week 13 - Association Rule Learning → Practical → grocery transactions, and then load transform it into one-hot encoded format and then load as a Pandas Dataframe.
(Hint: for this part, you may use the following code or modify as you see ?t:)
grocery items = set() with open("grocery transactions.txt") as f:
reader = csv.reader(f, delimiter=",") for i, line in enumerate(reader): grocery items.update(line)
output list = list() with open("grocery transactions.txt") as f:
reader = csv.reader(f, delimiter=",") for i, line in enumerate(reader):
row val = item:0 for item in grocery items row val.update(item:1 for item in line) output list.append(row val)
grocery = pd.DataFrame(output list)
grocery.head()
1.2 Using the apriori Class
Using the mlxtend.frequent patterns under Python as we covered on Week 13's lecture slides, determine the itemsets that has minimum support of 0.03.
1.3 Generating the Rules
Then for each of the following items below, if a customer buys some of them in the grocery store, then what other items are they also likely to purchase? (note: for
each one, please just list one item of you think is the most likely):
citrus fruit;
pastry;
rolls/buns;
root vegetables;
sausage;
tropical fruit;
whipped/sour cream;
yogurt;
Attachment:- Association Rule Learning.rar