5. 연관 규칙 분석 결과에서 confidence, lift 등 조건에 맞는 패턴 찾기
# association_rules 함수: 데이터프레임을 입력, 기본값(confidence), 향상도(lift) 등을 조건으로 사용, 각 metric별 사용하는 최솟값은 min_threshold로 지정하며, 기본값은 0.8로 지정 # Apriori 결과에서 패턴을 발견, 이때 최소 신뢰도는 0.7로 지정 >>> rules = association_rules(frequent_itemsets, metric = "confidence", min_threshold = 0.7) >>> rules 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 (Eggs) (Beans) 0.8 0.8 0.6 0.75 0.937500 -0.04 0.8 5 (Beans) (Eggs) 0.8 0.8 0.6 0.75 0.937500 -0.04 0.8 6 (Yogurt) (Beans) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 7 (Beans) (Yogurt) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 8 (Cookie) (Eggs) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 9 (Eggs) (Cookie) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 10 (Cookie, Eggs) (Beans) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 11(Cookie, Beans) (Eggs) 0.6 0.8 0.6 1.00 1.250000 0.12 inf 12 (Eggs, Beans) (Cookie) 0.6 0.6 0.6 1.00 1.666667 0.24 inf 13 (Cookie) (Eggs, Beans) 0.6 0.6 0.6 1.00 1.666667 0.24 inf 14 (Eggs) (Cookie, Beans) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6 15 (Beans) (Cookie, Eggs) 0.8 0.6 0.6 0.75 1.250000 0.12 1.6