当前位置 博文首页 > dastu的博客:学习笔记——XGBoost(极端梯度提升)推导终于会了!

    dastu的博客:学习笔记——XGBoost(极端梯度提升)推导终于会了!

    作者:[db:作者] 时间:2021-09-19 19:22

    一. XGBoost损失函数

    GBDT损失函数 L ( y i , f t ? 1 ( x ) + h t ( x ) ) L(y_i,f_{t-1}(x)+h_t(x)) L(yi?,ft?1?(x)+ht?(x))

    XGBoost在此基础上加入了正则化项 Ω ( h t ) = γ J + λ 2 ∑ j = 1 J w t j 2 \Omega(h_t)=\gamma J+\frac{\lambda}{2}\sum_{j=1}^J w_{tj}^2 Ω(ht?)=γJ+2λ?j=1J?wtj2?J为叶子节点个数, w t j w_{tj} wtj?为叶子节点的输出值。

    所以整体的损失函数就变为: L ≈ ∑ i = 1 m L ( y i , f t ? 1 ( x ) + h t ( x ) ) + γ J + λ 2 ∑ j = 1 J w t j 2 L \approx \sum_{i=1}^mL(y_i,f_{t-1}(x)+h_t(x))+\gamma J+\frac{\lambda}{2}\sum_{j=1}^J w_{tj}^2 Li=1m?L(yi?,ft?1?(x)+ht?(x))+γJ+2λ?j=1J?wtj2?样本个数为m。

    将损失函数L进行二阶展开(之所以这里是二阶展开而不是GBDT的一阶展开,可以参考牛顿法和梯度下降法)得到: L ≈ ∑ i = 1 m [ L ( y i , f t ? 1 ( x i ) ) + ? L ( y i , f t ? 1 ( x i ) ) ? f t ? 1 ( x i ) ? h t ( x ) + 1 2 ? 2 L ( y i , f t ? 1 ( x i ) ) ? 2 f t ? 1 ( x i ) ? h t 2 ( x ) ] + γ J + λ 2 ∑ j = 1 J w t j 2 L \approx \sum_{i=1}^m [ L(y_i,f_{t-1}(x_i))+\frac{\partial L(y_i,f_{t-1}(x_i))}{\partial f_{t-1}(x_i)}*h_t(x)+\frac{1}{2}\frac{\partial^2 L(y_i,f_{t-1}(x_i))}{\partial ^2f_{t-1}(x_i)}*h^2_t(x)]+\gamma J+\frac{\lambda}{2}\sum_{j=1}^J w_{tj}^2 Li=1m?[L(yi?,ft?1?(xi?))+?ft?1?(xi?)