多元逻辑回归公式推导

《统计学习方法》中关于多元逻辑回归公式推导,写的比较简单,正好前几天有同事对此比较疑惑,因此,在此进行详细推导,有助于大家共同学习。

首先,关于逻辑回归中二分类问题:
P ( Y = 1 ∣ x , ω ) = e x p ( ω ⋅ x + b ) 1 + e x p ( ω ⋅ x + b ) P(Y=1|x,\omega)=\frac{exp(\omega \cdot x+b)}{1+exp(\omega \cdot x+b)} P(Y=1x,ω)=1+exp(ωx+b)exp(ωx+b)
P ( Y = 0 ∣ x , ω ) = 1 1 + e x p ( ω ⋅ x + b ) P(Y=0|x,\omega)=\frac{1}{1+exp(\omega \cdot x+b)} P(Y=0x,ω)=1+exp(ωx+b)1
事件发生对数几率定义如下:
l o g P ( Y = 1 ∣ x , ω ) 1 − P ( Y = 0 ∣ x , ω ) = ω ⋅ x log \frac{P(Y=1|x,\omega)}{1-P(Y=0|x,\omega)}=\omega\cdot x log1P(Y=0x,ω)P(Y=1x,ω)=ωx

其次,关于对分类问题,可以看做多个二分类问题:
l o g P ( Y = 1 ∣ x ) P ( Y = K ∣ x ) = ω 1 ⋅ x log \frac{P(Y=1|x)}{P(Y=K|x)}=\omega_1\cdot x logP(Y=Kx)P(Y=1x)=ω1x
l o g P ( Y = i ∣ x ) P ( Y = K ∣ x ) = ω i ⋅ x log \frac{P(Y=i|x)}{P(Y=K|x)}=\omega_i\cdot x logP(Y=Kx)P(Y=ix)=ωix
l o g P ( Y = K − 1 ∣ x ) P ( Y = K ∣ x ) = ω K − 1 ⋅ x log \frac{P(Y=K-1|x)}{P(Y=K|x)}=\omega_{K-1}\cdot x logP(Y=Kx)P(Y=K1x)=ωK1x
因此有:
P ( Y = 1 ∣ x ) = P ( Y = K ∣ x ) ∗ e ω 1 ⋅ x P(Y=1|x)=P(Y=K|x) *e^{\omega_1\cdot x} P(Y=1x)=P(Y=Kx)eω1x
⋅ ⋅ ⋅ \cdot\cdot\cdot
P ( Y = i ∣ x ) = P ( Y = K ∣ x ) ∗ e ω i ⋅ x P(Y=i|x)=P(Y=K|x) *e^{\omega_i\cdot x} P(Y=ix)=P(Y=Kx)eωix
P ( Y = K − 1 ∣ x ) = P ( Y = K ∣ x ) ∗ e ω K − 1 ⋅ x P(Y=K-1|x)=P(Y=K|x) *e^{\omega_{K-1}\cdot x} P(Y=K1x)=P(Y=Kx)eωK1x
概率之和为1:
∑ i K P ( Y = i ∣ x , ω ) = 1 \sum^K_i P(Y=i|x, \omega)=1 iKP(Y=ix,ω)=1
联合上述K-1个、概率和式子,则有:
( 1 + ∑ i = 1 K − 1 e ω i ⋅ x ) ⋅ P ( Y = K ∣ x , ω ) = 1 (1+\sum ^{K-1}_{i=1}e^{\omega_i \cdot x})\cdot P(Y=K|x,\omega)=1 (1+i=1K1eωix)P(Y=Kx,ω)=1

P ( Y = K ∣ x , ω ) = 1 ( 1 + ∑ i = 1 K − 1 e ω i ⋅ x ) P(Y=K|x,\omega) = \frac{1}{(1+\sum ^{K-1}_{i=1}e^{\omega_i \cdot x})} P(Y=Kx,ω)=(1+i=1K1eωix)1
P ( Y = i ∣ x , ω ) = e ω i ⋅ x ( 1 + ∑ i = 1 K − 1 e ω i ⋅ x ) P(Y=i|x,\omega) = \frac{e^{\omega_i\cdot x}}{(1+\sum ^{K-1}_{i=1}e^{\omega_i \cdot x})} P(Y=ix,ω)=(1+i=1K1eωix)eωix
到此,全部推导完成。如果推导有疑问,欢迎大家一起交流!

你可能感兴趣的:(machine,learning,多元逻辑回归,公式推导)