ความสัมพันธ์และการต่อต้านความสัมพันธ์

Market Basket Analysis ด้วย Python

Isaiah Hull

Visiting Associate Professor of Finance, BI Norwegian Business School

ใช้การต่อต้านความสัมพันธ์เพื่อจับคู่ e-book

ภาพปกหนังสือ The Hobbit

ภาพปกหนังสือ The Great Gatsby

ภาพปกหนังสือ Pride and Prejudice

ภาพปกหนังสือ The Catcher in the Rye

1 ภาพจาก goodreads.com
Market Basket Analysis ด้วย Python

แนะนำ metric ของ Zhang

  1. เสนอโดย Zhang (2000)
    • มีค่าระหว่าง -1 ถึง +1
    • ค่า +1 หมายถึงความสัมพันธ์สมบูรณ์
    • ค่า -1 หมายถึงการต่อต้านความสัมพันธ์สมบูรณ์
  2. ครอบคลุมและตีความได้ง่าย
  3. สร้างจาก support
1 Zhang, T. (2000). Association Rules. Proceedings of the 4th Pacific-Asia conference, PADKK, pp.245-256. Kyoto, Japan.
Market Basket Analysis ด้วย Python

นิยาม metric ของ Zhang

  $$Zhang(A \rightarrow B) = $$ $$\frac{Confidence(A \rightarrow B) - Confidence(\bar{A} \rightarrow B)}{Max[Confidence(A \rightarrow B), Confidence(\bar{A} \rightarrow B)]}$$   $$Confidence = \frac{Support(A \& B)}{Support(A)}$$

Market Basket Analysis ด้วย Python

สร้าง metric ของ Zhang จาก support

  $$Zhang(A \rightarrow B) = $$ $$\frac{Support(A \& B) - Support(A) Support(B)}{ Max[Support(AB) (1-Support(A)), Support(A)(Support(B)-Support(AB))]}$$

Market Basket Analysis ด้วย Python

คำนวณ metric ของ Zhang

# Compute the support of each book
supportH = hobbit.mean()
supportP = pride.mean()
# Compute the support of both books
supportHP = np.logical_and(hobbit, pride).mean()
Market Basket Analysis ด้วย Python

คำนวณ metric ของ Zhang

# Compute the numerator
num = supportHP - supportH*supportP
# Compute the denominator
denom = max(supportHP*(1-supportH), supportH*(supportP-supportHP))
# Compute Zhang's metric
zhang = num / denom
print(zhang)
0.08903
Market Basket Analysis ด้วย Python

มาฝึกกันเถอะ!

Market Basket Analysis ด้วย Python

Preparing Video For Download...