# 향상도가 1.2 이상인 패턴을 발견 >>> rules2 = association_rules(frequent_itemsets, metric = "lift", min_threshold = 1.2) >>> rules2 antecedents consequents antecedent consequent support confidence lift leverage conviction support support -------------------------------------------------------------------------------------------------------------- 0 (Eggs) (Apple) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 1 (Apple) (Eggs) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 2 (Cookie) (Beans) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 3 (Beans) (Cookie) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 4 (Yogurt) (Beans) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 5 (Beans) (Yogurt) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 6 (Cookie) (Eggs) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 7 (Eggs) (Cookie) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 8 (Cookie, Eggs) (Beans) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 9 (Cookie, Beans) (Eggs) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 10 (Eggs, Beans) (Cookie) 0.6 0.6 0.6 1.00 1.666667 0.24 inf 11 (Cookie) (Eggs, Beans) 0.6 0.6 0.6 1.00 1.666667 0.24 inf 12 (Eggs) (Cookie, Beans) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 13 (Beans) (Cookie, Eggs) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 # 결과 중 필터링 # antecedents 열에 각 값에 포함된 item 개수를 len() 함수로 측정하여 antecedent_len이라는 새로운 열을 생성 >>> rules["antecedent_len"] = rules["antecedents"].apply(lambda x: len(x)) # 특정 조건을 만족하는 패턴을 출력 >>> rules[(rules['antecedent_len'] >= 2) & (rules['confidence'] > 0.75) & (rules['lift'] > 1.2)] antecedents consequents antecedent consequent support confidence lift leverage conviction antecedent_len support support ------------------------------------------------------------------------------------------------------------------------- 10 (Cookie, Eggs) (Beans) 0.6 0.8 0.6 1.0 1.250000 0.12 inf 2 11 (Cookie, Beans) (Eggs) 0.6 0.8 0.6 1.0 1.250000 0.12 inf 2 12 (Eggs, Beans) (Cookie) 0.6 0.6 0.6 1.0 1.666667 0.24 inf 2