Assignment 6
Assignment 6
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
In [7]: data = []
with open('Market_Basket_Optimisation.csv') as file:
reader = csv.reader(file, delimiter=',')
In [11]: len(data)
Out[11]: 7501
In [13]: te = TransactionEncoder()
x = te.fit_transform(data)
In [15]: x
In [17]: te.columns_
'honey',
'hot dogs',
'ketchup',
'light cream',
'light mayo',
'low fat yogurt',
'magazines',
'mashed potato',
'mayonnaise',
'meatballs',
'melons',
'milk',
'mineral water',
'mint',
'mint green tea',
'muffins',
'mushroom cream sauce',
'napkins',
'nonfat milk',
'oatmeal',
'oil',
'olive oil',
'pancakes',
'parmesan cheese',
'pasta',
'pepper',
'pet food',
'pickles',
'protein bar',
'red wine',
'rice',
'salad',
'salmon',
'salt',
'sandwich',
'shallot',
'shampoo',
'shrimp',
'soda',
'soup',
'spaghetti',
'sparkling water',
'spinach',
'strawberries',
'strong cheese',
'tea',
'tomato juice',
'tomato sauce',
'tomatoes',
'toothpaste',
'turkey',
'vegetables mix',
'water spray',
'white wine',
'whole weat flour',
'whole wheat pasta',
'whole wheat rice',
'yams',
'yogurt cake',
'zucchini']
In [21]: df
Out[21]:
antioxydant babies barbecue
asparagus almonds asparagus avocado bacon
juice food sauce
In [25]: freq_itemset
0 0.020397 (almonds)
1 0.033329 (avocado)
Out[31]: 2 (burgers)
25 (chocolate)
27 (eggs)
29 (french fries)
31 (frozen vegetables)
32 (green tea)
34 (milk)
37 (mineral water)
39 (pancakes)
41 (spaghetti)
Name: consequents, dtype: object
In [ ]: