Gradient boosting
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)$
程序中使用:
损失函数 $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的更多相关文章
- Gradient Boosting Decision Tree学习
Gradient Boosting Decision Tree,即梯度提升树,简称GBDT,也叫GBRT(Gradient Boosting Regression Tree),也称为Multiple ...
- 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 ...
- How to Configure the Gradient Boosting Algorithm
How to Configure the Gradient Boosting Algorithm by Jason Brownlee on September 12, 2016 in XGBoost ...
- Ensemble Learning 之 Gradient Boosting 与 GBDT
之前一篇写了关于基于权重的 Boosting 方法 Adaboost,本文主要讲述 Boosting 的另一种形式 Gradient Boosting ,在 Adaboost 中样本权重随着分类正确与 ...
- GBDT(Gradient Boosting Decision Tree)算法&协同过滤算法
GBDT(Gradient Boosting Decision Tree)算法参考:http://blog.csdn.net/dark_scope/article/details/24863289 理 ...
- 机器学习中的数学(3)-模型组合(Model Combining)之Boosting与Gradient Boosting
版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...
- Jackknife,Bootstraping, bagging, boosting, AdaBoosting, Rand forest 和 gradient boosting的区别
引自http://blog.csdn.net/xianlingmao/article/details/7712217 Jackknife,Bootstraping, bagging, boosting ...
- 模型组合(Model Combining)之Boosting与Gradient Boosting
版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...
- 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 ...
随机推荐
- 过河问题--nyoj题目47
过河问题 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 在漆黑的夜里,N位旅行者来到了一座狭窄而且没有护栏的桥边.如果不借助手电筒的话,大家是无论如何也不敢过桥去的 ...
- Train Problem I
问题陈述: 杭州电子科技大学HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1022 问题解析: 栈(stack)的简单应用 代码详解: #incl ...
- MYSQL select ....outfile.....from.....
select .... outfile 'file_path' fields terminate by '\t' lines terminate by '\r\n' from table_name; ...
- DataGridView 去掉多余的列
去掉DataGridView多余的列: this.DataGridView.AutoGenerateColumns = false;
- 时间TDateTime相当于是Double,即双精度数64位,终于查到它用11位表示e,53位表示精度(整数小数一起),最前面一位表示正负
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Internal_Data_Formats 关于Double的RTL函数,好像就一个:TrySt ...
- Inno Setup 安装inf文件的一个例子
原文 http://zwkufo.blog.163.com/blog/static/2588251201063033524889/ ; INF安装例子; [Setup]; 注意: AppId 的值是唯 ...
- cf452A Eevee
A. Eevee time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- cp | mv | rm
linux下文件的复制.移动与删除命令为:cp,mv,rm 一.文件复制命令cp 命令格式: cp [-adfilprsu] 源文件(source) 目标文件(destination) cp [opt ...
- Centos下编译Linux内核
Linux内核编译是一件简单却费事的事.但是独立的编译linux内核会帮助你很好的理解Linux内核的工作机理. 首先编译linux内核我们需要在当前linux操作系统下安装gcc编译器,因为我是Ce ...
- C与C++动态分配二维数组
C: C中使用函数malloc和free两个函数. //动态分配M*N维 int **a=(int **)malloc(sizeof(int*)*M); ;i<M;i++) a[i]=(int ...