杠杆率与确信度

Python 中的购物篮分析

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)}$$

Python 中的购物篮分析

杠杆率指标

  • 杠杆率同样基于支持度

 

$$Leverage(X \rightarrow Y) = $$ $$Support(X \& Y) - Support(X) Support(Y)$$

  • 杠杆率类似于提升度,但更易解读
  • 杠杆率范围为 -1 到 +1
    • 提升度范围为 0 到无穷大。
Python 中的购物篮分析

计算杠杆率

# 计算《暮光之城》和《哈利·波特》的支持度
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
Python 中的购物篮分析

确信度指标

  1. 确信度也由支持度构建。
  2. 杠杆率更复杂、直觉性更差。

 

$$Conviction(X \rightarrow Y) = $$ $$\frac{Support(X) Support(\bar{Y})} {Support(X \& \bar{{Y}})}$$

Python 中的购物篮分析

解释确信度

《暮光之城》的缩略图。

《哈利·波特与魔法石》的缩略图。

《暮光之城》的缩略图。

《饥饿游戏》的缩略图。

1 图片来自 goodreads.com。
Python 中的购物篮分析

计算确信度

# 计算《暮光之城》和《哈利·波特》的支持度
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 中的购物篮分析

Passons à la pratique !

Python 中的购物篮分析

Preparing Video For Download...