3. mlxtend의 Apriori 알고리즘 적용하기
>>> import mlxtend >>> from mlxtend.frequent_patterns import apriori >>> from mlxtend.frequent_patterns import association_rules >>> apriori(df, min_support = 0.6) # 최소 지지도를 0.6으로 하여 Apriori에 적용하기 support itemsets ----------------------- 0 0.6 (0) 1 0.8 (1) 2 0.6 (3) 3 0.8 (5) 4 0.6 (8) 5 0.6 (10) 6 0.6 (0, 5) 7 0.6 (1, 3) 8 0.6 (1, 5) 9 0.6 (1, 10) 10 0.6 (3, 5) 11 0.6 (1, 3, 5)
# itemsets에 제품명이 나오도록 지정 >>> apriori(df, min_support = 0.6, use_colnames = True) support itemsets ---------------------------------- 0 0.6 (Apple) 1 0.8 (Beans) 2 0.6 (Cookie) 3 0.8 (Eggs) 4 0.6 (Milk) 5 0.6 (Yogurt) 6 0.6 (Eggs, Apple) 7 0.6 (Cookie, Beans) 8 0.6 (Eggs, Beans) 9 0.6 (Yogurt, Beans) 10 0.6 (Cookie, Eggs) 11 0.6 (Eggs, Cookie, Beans)