Python으로 배우는 Market Basket Analysis
Isaiah Hull
Visiting Associate Professor of Finance, BI Norwegian Business School
$$Support(X) = \frac{Frequency(X)}{N}$$
$$Support(X \rightarrow Y) = \frac{Frequency(X \& Y)}{N}$$
$$Confidence(X \rightarrow Y) = \frac{Support(X \rightarrow Y)} {Support(X)}$$
$$Lift(X \rightarrow Y) = \frac{Support(X \rightarrow Y)}{Support(X) Support(Y)}$$
$$Leverage(X \rightarrow Y) = $$ $$Support(X \& Y) - Support(X) Support(Y)$$
# 트와일라잇과 해리 포터의 지지도 계산
supportTP = np.logical_and(books['Twilight'], books['Potter']).mean()
# 트와일라잇의 지지도 계산
supportT = books['Twilight'].mean()
# 해리 포터의 지지도 계산
supportP = books['Potter'].mean()
# 레버리지 계산 및 출력
leverage = supportTP - supportP * supportT
print(leverage)
0.018
$$Conviction(X \rightarrow Y) = $$ $$\frac{Support(X) Support(\bar{Y})} {Support(X \& \bar{{Y}})}$$




# 트와일라잇과 해리 포터의 지지도 계산 supportTP = np.logical_and(books['Twilight'], books['Potter']).mean() # 트와일라잇의 지지도 계산 supportT = books['Twilight'].mean()# 해리 포터가 아닌 것의 지지도 계산 supportnP = 1.0 - books['Potter'].mean()# 트와일라잇 그리고 해리 포터가 아닌 것의 지지도 계산 supportTnP = supportT - supportPT# 컨빅션 계산 conviction = supportT*supportnP / supportTnP print(conviction)1.16
Python으로 배우는 Market Basket Analysis