Gradient boosting

gradient boosting 是一种boosting(组合弱学习器得到强学习器)算法中的一种,可以把学习算法(logistic regression,decision tree)代入其中。

问题描述:

给定一组数据{(x,y)}i,i=1,2...,N,使用函数F(x)对数据进行拟合,使对于给定损失函数L(y,F(x))最小

(损失函数可以为$(y-F(x))^2,|y-F(x)|$[regression],$log(1+e^{-2yF})$[classification])

使用$F(x)=F_0(x)+\sum_{m=1}^{M}r_ih_m(x;\alpha_m)$(1)

$F_0(x)=argmin_r\sum_{i=1}^N L(y_i,r)$为初始值;为常数;$r_i$为权重

$h_m(x;\alpha_m)$是某个弱学习算法(logistic regression,decision tree),$\alpha_m$为算法的参数

算法描述:

首先选取一个常数作为F(x)的估计,最优的常数需要使损失函数最小

1.初始化$F_0(x)=argmin_r\sum_{i=1}^N L(y_i,r)$

现在已经有了$F_0(x)$作为$F(x)$的初始估计,考虑使用gredient decent方法,使损失函数减少

  A.选取方向$g_m=-\left[\frac{\partial L(y,F(x))}{\partial F(x)}\right]_{F(x)=F_{m-1}(x)}$

  B.选取方向后,选取步长,$\beta_m=argmin_{\beta}\sum_{i=1}^{N}L(y_i,F_{m-1}(x_i)+\beta g_m)$

对照(1)式,$g_m$(称为残差,residual)即为$h_m(x;\alpha_m)$;$\beta_m$即为$r_m$

2.计算$g_m$,使用$h_m(x;\alpha_m)$拟合${x,g_m}_1^N$,得到参数$\alpha_m$和$h_m(x)$的值

计算$r_m=argmin_r\sum_{i=1}^{N}L(y_i,F_{m-1}(x_i)+rh_m(x))$

3.更新$F_m(x)=F_{m-1}(x)+r_mh_m(x)$

4.循环2,3两步,得到F_M(x)

输出:算法结束后,得到以下参数$(r_0,r_1,r_2,...,r_M,\alpha_1,\alpha_2,...,\alpha_M)$

当作预测时:$F(c)=r_0+\sum_{i=1}^{M}r_ih_i(c;\alpha_i)$

Demo(程序数据) matlab

程序中使用:

损失函数   $L(y,F(x))=\frac{1}{N}\sum_{i=1}{N}(y_i-F(x_i))^2$

弱学习算法  spline regression 参看Intro_to_splines(实际就是加了特征转换的regression)

注意:程序中的predict实现是错误的;程序没有计算步长$r_m$,而是使用常数

for i=1:nboost
% 计算残差g_m,residual
gradient = -2/nTrain * (f-y); % 用h_m拟合{(x,g_m)}
submodel = boostedModel(X,gradient,options); % 作者实现中,对每个特征生成一个spline regression,下列代码选出表现最好的特征
diff = (submodel - Y).^2;
err = sum(diff,1)/nTrain;
best(i) = find( err == min(err));
f_i = submodel(:,best(i));
% 如果需要预测,需要保存 spline regression 的两个参数,
% 特征i和参数alpha(regression每个特征上的权重)
%
% 以及训练spline regression时用的knote及Degree参数 % 没有计算步长(权重),直接使用常数,1-500次循环时,v=0.9
if i>500
v = 0.5;
end
%更新F_m(x)
f = f + v*f_i; if mod(i,100) == 0
n = n+1;
error(n) = 1/nTrain * sum((y - f).^2);
end end

Gradient boosting的更多相关文章

  1. Gradient Boosting Decision Tree学习

    Gradient Boosting Decision Tree,即梯度提升树,简称GBDT,也叫GBRT(Gradient Boosting Regression Tree),也称为Multiple ...

  2. A Gentle Introduction to the Gradient Boosting Algorithm for Machine Learning

    A Gentle Introduction to the Gradient Boosting Algorithm for Machine Learning by Jason Brownlee on S ...

  3. How to Configure the Gradient Boosting Algorithm

    How to Configure the Gradient Boosting Algorithm by Jason Brownlee on September 12, 2016 in XGBoost ...

  4. Ensemble Learning 之 Gradient Boosting 与 GBDT

    之前一篇写了关于基于权重的 Boosting 方法 Adaboost,本文主要讲述 Boosting 的另一种形式 Gradient Boosting ,在 Adaboost 中样本权重随着分类正确与 ...

  5. GBDT(Gradient Boosting Decision Tree)算法&协同过滤算法

    GBDT(Gradient Boosting Decision Tree)算法参考:http://blog.csdn.net/dark_scope/article/details/24863289 理 ...

  6. 机器学习中的数学(3)-模型组合(Model Combining)之Boosting与Gradient Boosting

    版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...

  7. Jackknife,Bootstraping, bagging, boosting, AdaBoosting, Rand forest 和 gradient boosting的区别

    引自http://blog.csdn.net/xianlingmao/article/details/7712217 Jackknife,Bootstraping, bagging, boosting ...

  8. 模型组合(Model Combining)之Boosting与Gradient Boosting

    版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...

  9. Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍

    xgboost的可以参考:https://xgboost.readthedocs.io/en/latest/gpu/index.html 整体看加速5-6倍的样子. Gradient Boosting ...

随机推荐

  1. ReactNative

    基于ReactNative实现的博客园手机客户端   去年九月,facebook发布了react-native,将web端的javaScript和react技术扩展到了IOS和Android的原生应用 ...

  2. MYSQL 查看可用的字符集的 2 方法

    方法 1. show character set; 方法 2. show collation;

  3. View, Activity, Window

    View, Activity, Window 2010-03-02 10:42:56|  分类: android|举报|字号 订阅     对于屏幕显示而言,整个是window,这个window里显示 ...

  4. 2014第7周四excel多列文本复制技巧

    刚才win8.1强制安装更新后重启,然后一直显示“安装更新失败正在,正在撤销更改,请不要关闭计算机”,等了很久还是不行,我还是强制按下了电源按钮,然后再次开机还是这样,实在没办法只能等,过了N久后没想 ...

  5. 【男性身材计算】胸围=身高*0.48(如:身高175cm的标准胸围=175cm*0.61=84cm);腰围=身高*0.47(如:身高175c… - 李峥 - 价值中国网

    [男性身材计算]胸围=身高*0.48(如:身高175cm的标准胸围=175cm*0.61=84cm):腰围=身高*0.47(如:身高175c- - 李峥 - 价值中国网 李峥:[男性身材计算]胸围=身 ...

  6. [置顶] Ajax核心--XMLHttpRequest对象

    XMLHttpRequest 对象是AJAX功能的核心,学习XMLHttpRequest对象就先从创建XMLHttpRequest 对象开始,了解在不同的浏览器中创建XMLHttpRequest 对象 ...

  7. #include <boost/scoped_ptr.hpp>

    多个元素使用#include <boost/scoped_array.hpp> 单个元素使用#include <boost/scoped_ptr.hpp> 作用域指针 它独占一 ...

  8. leetcode_question_130 Surrounded Regions

    Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured ...

  9. Cocos2d-x 3.1.1 Lua演示样例 ActionEaseTest(动作)

    Cocos2d-x Lua演示样例 ActionEaseTest(动作)   本篇博客介绍Cocos2d-x中的动作,Cocos2d-x为我们提供了丰富的动作接口,以下笔者就具体介绍一下:   本系列 ...

  10. android soundpool 參数说明

    SoundPool 类的构造函数例如以下: SoundPool(int maxStreams, int streamType, int srcQuality) 作用:实例化一个SoundPool 实例 ...