逻辑回归

逻辑回归

  1. 逻辑回归的梯度下降法推导

  2. 逻辑回归目标函数为凸函数

训练数据 D = { ( x 1 , y 1 ) , ⋯   , ( x n , y n ) } D = \{ (\mathbf{x}_{1}, y_{1}), \cdots, (\mathbf{x}_{n}, y_{n}) \} D={ (x1,y1),,(xn,yn)},其中 ( x i , y i ) (\mathbf{x}_{i}, y_{i}) (xi,yi)表示 一条样本, x i ∈ R D \mathbf{x}_{i} \in \R^{D} xiRD D D D维样本特征(feature), y i ∈ { 0 , 1 } y_{i} \in \{ 0, 1\} yi{ 0,1}表示样本标签(label)。

逻辑回归模型的参数为 ( w , b ) (\mathbf{w}, b) (w,b)。为推导方便,通常将 b b b整合到 w \mathbf{w} w中,此时, w \mathbf{w} w x i \mathbf{x}_{i} xi分别改写为

w = [ w 0 , w 1 , ⋯   , w D ] ,   x i = [ 1 , x 1 , ⋯   , x D ] \mathbf{w} = [w_{0}, w_{1}, \cdots, w_{D}], \ \mathbf{x}_{i} = [1, x_{1}, \cdots, x_{D}] w=[w0,w1,,wD], xi=[1,x1,,xD]

1 逻辑回归的目标函数

目标函数(objective function),也称为损失函数(loss function),记为 L ( w ) \mathcal{L} (\mathbf{w}) L(w)

二分类问题模型

p ( y ∣ x ; w ) = p ( y = 1 ∣ x ; w ) y [ 1 − p ( y = 1 ∣ x ; w ) ] 1 − y (1) p(y | \mathbf{x}; \mathbf{w} ) = p(y = 1 | \mathbf{x}; \mathbf{w})^{y} [1 - p(y = 1 | \mathbf{x}; \mathbf{w})]^{1 - y} \tag {1} p(yx;w)=p(y=1x;w)y[1p(y=1x;w)]1y(1)

最大似然估计(MLE)

w ∗ = arg ⁡ max ⁡ w p ( y ∣ x ; w ) = arg ⁡ max ⁡ w ∏ i = 1 n p ( y i ∣ x i ; w ) = arg ⁡ max ⁡ w log ⁡ [ ∏ i = 1 n p ( y i ∣ x i ; w ) ] = arg ⁡ max ⁡ w ∑ i = 1 n log ⁡ [ p ( y i ∣ x i ; w ) ] = arg ⁡ max ⁡ w ∑ i = 1 n log ⁡ [ p ( y i = 1 ∣ x i ; w ) y i [ 1 − p ( y i = 1 ∣ x i ; w ) ] 1 − y i ] = arg ⁡ max ⁡ w ∑ i = 1 n [ y i log ⁡ p ( y i = 1 ∣ x i ; w ) + ( 1 − y i ) log ⁡ [ 1 − p ( y i = 1 ∣ x i ; w ) ] ] (2) \begin{aligned} \mathbf{w}^{\ast} & = \arg \max_{\mathbf{w}} p(\mathbf{y} | \mathbf{x}; \mathbf{w} ) \\ & = \arg \max_{\mathbf{w}} \prod_{i = 1}^{n} p(y_{i} | \mathbf{x}_{i}; \mathbf{w} ) \\ & = \arg \max_{\mathbf{w}} \log \left[ \prod_{i = 1}^{n} p(y_{i} | \mathbf{x}_{i}; \mathbf{w} ) \right] \\ & = \arg \max_{\mathbf{w}} \sum_{i = 1}^{n} \log \left[ p(y_{i} | \mathbf{x}_{i}; \mathbf{w} ) \right] \\ & = \arg \max_{\mathbf{w}} \sum_{i = 1}^{n} \log \left[ p(y_{i} = 1 | \mathbf{x}_{i}; \mathbf{w})^{y_{i}} [1 - p(y_{i} = 1 | \mathbf{x}_{i}; \mathbf{w})]^{1 - y_{i}} \right] \\ & = \arg \max_{\mathbf{w}} \sum_{i = 1}^{n} \left[ y_{i} \log p(y_{i} = 1 | \mathbf{x}_{i}; \mathbf{w}) + (1 - y_{i}) \log [1 - p(y_{i} = 1 | \mathbf{x}_{i}; \mathbf{w})] \right] \\ \end{aligned} \tag {2} w=argwmaxp(yx;w)=argwmaxi=1np(yixi;w)=argwmaxlog[i=1np(y

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值