Weighted Logistic Regression和Youtube时长预估

前段时间阅读了youtube的经典论文《Deep Neural Networks for YouTube Recommendations》,其通过weighted LR来实现时长预估,在其原文中对实现的描述非常短,大概意思是在损失函数中,对正例(点击)的交叉熵项,添加观看时长T_i作为权重,会使得LR预估的odds=\theta X能代表观看时长,即e^{\theta X}可以表示对观看时长的预估,这篇论文很多博文都分析烂大街了,但对于weighted LR来实现时长预估的原理,很多博主分析都很有问题,或者分析似是而非,本文将会从最本质来说明其实现思想。

The model is trained with logistic regression under crossentropy loss . However, the positive (clicked) impressions are weighted by the observed watch time on the video. Negative (unclicked) impressions all receive unit weight. In this way, the odds learned by the logistic regression are  \sum{T_i}/(N-k), where N is the number of training examples, k is the number of positive impressions, and T_i is the watch time of the ith impression. Assuming the fraction of positive impressions is small (which is true in our case), the learned odds are approximately E(T)(1+P), where P is the click probability and E(T) is the expected watch time of the impression. Since P is small, this product is close to E(T). For inference we use the exponential function e x as the final activation function to produce these odds that closely estimate expected watch time.

首先要说明的一点的是,基础LR主要是解决分类问题的概率p估计,假设对于一个二分类问题,模型的目标是预估label=1的概率p,其结构大概分成两个部分:

  • 通过线性回归拟合几率,其中p/1-p表示的是几率,\theta表示的模型的参数,X表示输入(式1):

log\frac{p}{1-p} = Wx + b = \theta X                                                                                       

  • 通过sigmord函数转换为p值(式2):

p=\frac{e^{\theta X}}{1+e^{\theta X}}                                                                                                              

  • 模型的优化目标(式3):

argmax \prod P(y_i|label=1)P(1-y_i|label=0) = argmax \prod P(y_i)^{label}P(1-y_i)^{1-label}     

  • 其损失函数可以表示为,即交叉熵函数(式4):

Loss =-[\sum label_i \cdot log(p_i) + (1 - label_i) \cdot log(1 - p_i)]

说完了基本LR的形式,我们回到Youtube的weighted LR的情况下,其主要是在交叉熵Loss函数添加了权重值,即正例用观看时长T_i作为权重值,负例的权重值为1,如下label我直接用click_i表示(式5):

Loss =-[\sum T_i \cdot click_i \cdot log(p_i) + 1 \cdot (1 - click_i) \cdot log(1 - p_i)] 

在论文中简单说明了下,如果损失函数通过这种权重设计后,经过训练,LR的输出就由原来的(式1)变为(式6):

log\frac{t p}{1-p} = Wx + b = \theta X

此处的tp表示对时长期望E(T)的预估,在p值远小于1的情况下,存在如下的近似形式(式7),即e^{\theta X}可以表示对观看时长的预估。 

 \frac{E(T)}{1-p} = e^{\theta X} \approx \frac{E(T)(1-p^2)}{1-p} \approx E(T)(1+p) \approx E(T)

现在最大的问题是,如何由带权重值的Loss(式5)推导出(式6)的结果:

  • 假设(式6)经过sigmord函数转换为(式8)

\tilde{p} = \frac{e^{\theta X}}{1+e^{\theta X}} = \frac{tp}{1-p} *\frac{1-p}{1-p+tp} = \frac{tp}{1-p + tp}

1- \tilde{p} = \frac{1-p}{1-p + tp}

  • 此时我们对比(式8)和(式2),在新weighted LR模型下,预估的label由变成了t * label,而负例仍为1-label,此时还是二分类问题,只是预估的label有变化,因此我们的优化目标变成如下(式9)

argmax \prod [P(y_i)^{label}]^{T_i}P(1-y_i)^{1-label}=argmax \prod P(y_i)^{label\cdot T_i}P(1-y_i)^{1-label}

  • 其损失函数可以表示为(式9),即同(式5)的形式:

Loss =-[\sum T_i \cdot click_i \cdot log(P(y_i)) + 1 \cdot (1 - click_i) \cdot log(1 - P(y_i))] 

总结:youtube采用weighted LR对时长进行预估的方式,实在是非常巧妙。对于时长等连续值预估的回归模型一直以来都相对复杂,而youtube仅仅只是通过调整损失函数的正例项权重值,就将原来由对点击率预估转换为对时长的预估,这里面虽然看起来简单,其中的一些细节值得反复思考。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值