여정의 기록
apriori 본문
pruming 가지치기 ( 상관없는 데이터가 포함되는 경우의 수를 제외시킨다)
datarules <- apriori(data, parameter = list(support=0.006, confidence=0.25, minlen=2))
최소 support와 최소 confidence 를 지정해줌으로써 데이터를 추려낸다.
Apriori Parameter specification: confidence minval smax arem aval originalSupport maxtime
support 0.8 0.1 1 none FALSE TRUE 5 0.1 minlen maxlen target ext 1 10 rules TRUE Algorithmic control: filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE Absolute minimum support count: 983 set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[169 item(s), 9835 transaction(s)] done [0.01s].
sorting and recoding items ... [8 item(s)] done [0.00s]. creating transaction tree ... done [0.00s].
checking subsets of size 1 2 done [0.00s]. writing ... [0 rule(s)] done [0.00s]. creating S4 object ... done [0.00s].
set of 0 rules
Apriori Parameter specification: confidence minval smax arem aval originalSupport maxtime
support 0.25 0.1 1 none FALSE TRUE 5 0.006 minlen maxlen target ext 2 10 rules TRUE Algorithmic control: filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE Absolute minimum support count: 59 set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s]. sorting and recoding items ... [109 item(s)] done [0.00s]. creating transaction tree ... done [0.00s]. checking subsets of size 1 2 3 4 done [0.01s]. writing ... [463 rule(s)] done [0.00s]. creating S4 object ... done [0.00s].
if lhs then rhs
inspect(data)
lift 에서 1보다 큰 애들을 봐야함
근데 데이터를 보면 lhs에서 공집합인 경우가 있다. (before 공집합인 경우 after 뭔가 했을 확률을 배제하고자한다면)
apriori 에서 minlen을 정해준다.
공집합을 제거함으로 써 464개 -> 463개로 감소
summary(data)
set of 463 rules : 463개의 rule로 구성
rule length ... sizes : 한 건당 구매한 총 상품수 (해당 행의 총합)
lift max 값은?
정렬을 해보자
inspect(sort(data, by="lift")[1:30]) # lift열 기준 정렬
특정 데이터에 대한 연관규칙을 검색
beefrules <- subset(data, items %in% "beef")
inspect(beefrules)
inspect(sort(beefrules, by="lift")[1:5])
'공부 > Algorithm' 카테고리의 다른 글
[MySql] WITH RECURSIVE 가상 테이블 이용하기 (0) | 2023.01.03 |
---|---|
SQL , LIKE % AND UPPER (0) | 2022.12.28 |
간단한 모델링 과정, 주의점 (0) | 2022.02.14 |
추천시스템_연관규칙(rule)(지지도,신뢰도,향상도, 의미없는 연관규칙 최소화) (0) | 2021.09.16 |
데이터 들여다보기와 Cluster 클러스터: K-mean (0) | 2021.09.07 |