Python ile 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)$$
# Twilight ve Harry Potter için support'u hesapla
supportTP = np.logical_and(books['Twilight'], books['Potter']).mean()
# Twilight için support'u hesapla
supportT = books['Twilight'].mean()
# Harry Potter için support'u hesapla
supportP = books['Potter'].mean()
# Leverage'ı hesapla ve yazdır
leverage = supportTP - supportP * supportT
print(leverage)
0.018
$$Conviction(X \rightarrow Y) = $$ $$\frac{Support(X) Support(\bar{Y})} {Support(X \& \bar{{Y}})}$$




# Twilight ve Harry Potter ve Twilight için support'u hesapla
supportTP = np.logical_and(books['Twilight'], books['Potter']).mean()
supportT = books['Twilight'].mean()
# Harry Potter OLMAYAN için support'u hesapla
supportnP = 1.0 - books['Potter'].mean()
# Twilight ve Harry Potter OLMAYAN için support'u hesapla
supportTnP = supportT - supportPT
# Conviction'ı hesapla
conviction = supportT*supportnP / supportTnP
print(conviction)
1.16
Python ile Market Basket Analysis