机器学习xgboost参数解释笔记
首先xgboost有两种接口,xgboost自带API和Scikit-Learn的API,具体用法有细微的差别但不大。
在运行 XGBoost 之前, 我们必须设置三种类型的参数: (常规参数)general parameters,(提升器参数)booster parameters和(任务参数)task parameters。
常规参数与我们用于提升的提升器有关,通常是树模型或线性模型
提升器参数取决于你所选择的提升器
学习任务的参数决定了学习场景, 例如回归任务可以使用不同的参数进行排序相关的任务
命令行参数的行为与 xgboost 的 CLI 版本相关
本文只介绍xgboost自带的API,Scikit-Learn的API可以对照参考。
xgboost.train(params, dtrain, num_boost_round=10, evals=(), \
obj=None, feval=None, maximize=False, early_stopping_rounds=None, \
evals_result=None, verbose_eval=True, learning_rates=None, \
xgb_model=None, callbacks=None)
params
:这是一个字典,里面包含着训练中的参数关键字和对应的值,形式如下:
params = {
'booster':'gbtree',
'min_child_weight': 100,
'eta': 0.02,
'colsample_bytree': 0.7,
'max_depth': 12,
'subsample': 0.7,
'alpha': 1,
'gamma': 1,
'silent': 1,
'objective': 'reg:linear',
'verbose_eval': True,
'seed': 12
}
其中具体的参数以下会介绍。
General Parameters
booster [default=gbtree]
有两中模型可以选择gbtree和gblinear。gbtree使用基于树的模型进行提升计算,gblinear使用线性模型进行提升计算。缺省值为gbtree。
silent [default=0]
取0时表示打印出运行时信息,取1时表示以缄默方式运行,不打印运行时信息。缺省值为0。
nthread [default to maximum number of threads available if not set]
XGBoost运行时的线程数。缺省值是当前系统可以获得的最大线程数
num_pbuffer [set automatically by xgboost, no need to be set by user]
size of prediction buffer, normally set to number of training instances. The buffers are used to save the prediction results of last boosting step.
num_feature [set automatically by xgboost, no need to be set by user]
boosting过程中用到的特征维数,设置为特征个数。XGBoost会自动设置,不需要手工设置。
Booster Parameters
eta [default=0.3]
为了防止过拟合,更新过程中用到的收缩步长。在每次提升计算之后,算法会直接获得新特征的权重。 eta通过缩减特征的权重使提升计算过程更加保守。缺省值为0.3
取值范围为:[0,1]
gamma [default=0]
minimum loss reduction required to make a further partition on a leaf node of the tree. the larger, the more conservative the algorithm will be.
range: [0,∞]
max_depth [default=6]
数的最大深度。缺省值为6
取值范围为:[1,∞]
min_child_weight [default=1]
孩子节点中最小的样本权重和。如果一个叶子节点的样本权重和小于min_child_weight则拆分过程结束。在现行回归模型中,这个参数是指建立每个模型所需要的最小样本数。该成熟越大算法越conservative
取值范围为: [0,∞]
max_delta_step [default=0]
Maximum delta step we allow each tree’s weight estimation to be. If the value is set to 0, it means there is no constraint. If it is set to a positive value, it can help making the update step more conservative. 通常不需要这个参数,但是当类非常不平衡时,它可能有助于逻辑回归。将其设置为1-10可能有助于控制更新
取值范围为:[0,∞]
subsample [default=1]
用于训练模型的子样本占整个样本集合的比例。如果设置为0.5则意味着XGBoost将随机的冲整个样本集合中随机的抽取出50%的子样本建立树模型,这能够防止过拟合。
取值范围为:(0,1]
colsample_bytree [default=1]
在建立树时对特征采样的比例。缺省值为1
取值范围:(0,1]
Task Parameters
objective [ default=reg:linear ]
定义学习任务及相应的学习目标,可选的目标函数如下:
“reg:linear” –线性回归。
“reg:logistic” –逻辑回归。
“binary:logistic”–二分类的逻辑回归问题,输出为概率。
“binary:logitraw”–二分类的逻辑回归问题,输出的结果为wTx。
“count:poisson”–计数问题的poisson回归,输出结果为poisson分布。在poisson回归中,max_delta_step的缺省值为0.7。(used to safeguard optimization)
“multi:softmax” –让XGBoost采用softmax目标函数处理多分类问题,同时需要设置参数num_class(类别个数)
“multi:softprob” –和softmax一样,但是输出的是ndata * nclass的向量,可以将该向量reshape成ndata行nclass列的矩阵。没行数据表示样本所属于每个类别的概率。
“rank:pairwise”–set XGBoost to do ranking task by minimizing the pairwise loss
base_score [ default=0.5 ]
the initial prediction score of all instances, global bias
eval_metric [ default according to objective ]
校验数据所需要的评价指标,不同的目标函数将会有缺省的评价指标(rmse for regression, and error for classification, mean average precision for ranking)
用户可以添加多种评价指标,对于Python用户要以list传递参数对给程序,而不是map参数list参数不会覆盖’eval_metric’
The choices are listed below:
“rmse”: root mean square error
“logloss”: negative log-likelihood
“error”: Binary classification error rate. It is calculated as #(wrong cases)/#(all cases). For the predictions, the evaluation will regard the instances with prediction value larger than 0.5 as positive instances, and the others as negative instances.
“merror”: Multiclass classification error rate. It is calculated as #(wrong cases)/#(all cases).
“mlogloss”: Multiclass logloss
“auc”: Area under the curve for ranking evaluation.
“ndcg”:Normalized Discounted Cumulative Gain
“map”:Mean average precision
“ndcg@n”,”map@n”: n can be assigned as an integer to cut off the top positions in the lists for evaluation.
“ndcg-”,”map-”,”ndcg@n-”,”map@n-”: In XGBoost, NDCG and MAP will evaluate the score of a list without any positive samples as 1. By adding “-” in the evaluation metric XGBoost will evaluate these score as 0 to be consistent under some conditions. training repeatively
“gamma-deviance”: [residual deviance for gamma regression]
seed[ default=0 ]
random number seed.
随机数的种子。缺省值为0
dtrain:训练的数据
num_boost_round:这是指提升迭代的次数,也就是生成多少基模型
evals:这是一个列表,用于对训练过程中进行评估列表中的元素。形式是evals = [(dtrain,'train'),(dval,'val')]或者是evals = [(dtrain,'train')],对于第一种情况,它使得我们可以在训练过程中观察验证集的效果
obj:自定义目的函数
feval:自定义评估函数
maximize:是否对评估函数进行最大化
early_stopping_rounds:早期停止次数 ,假设为100,验证集的误差迭代到一定程度在100次内不能再继续降低,就停止迭代。这要求evals 里至少有 一个元素,如果有多个,按最后一个去执行。返回的是最后的迭代次数(不是最好的)。如果early_stopping_rounds存在,则模型会生成三个属性,bst.best_score,bst.best_iteration和bst.best_ntree_limit
evals_result:字典,存储在watchlist中的元素的评估结果。
verbose_eval :(可以输入布尔型或数值型),也要求evals里至少有 一个元素。如果为True,则对evals中元素的评估结果会输出在结果中;如果输入数字,假设为5,则每隔5个迭代输出一次。
learning_rates:每一次提升的学习率的列表,
xgb_model:在训练之前用于加载的xgb model。
以上原文链接https://blog.csdn.net/iyuanshuo/article/details/80142730
机器学习xgboost参数解释笔记的更多相关文章
- 机器学习总结-sklearn参数解释
本文转自:lytforgood 机器学习总结-sklearn参数解释 实验数据集选取: 1分类数据选取 load_iris 鸢尾花数据集 from sklearn.datasets import lo ...
- XGBoost参数调优完全指南(附Python代码)
XGBoost参数调优完全指南(附Python代码):http://www.2cto.com/kf/201607/528771.html https://www.zhihu.com/question/ ...
- 《机器学习实战》学习笔记第九章 —— 决策树之CART算法
相关博文: <机器学习实战>学习笔记第三章 —— 决策树 主要内容: 一.CART算法简介 二.分类树 三.回归树 四.构建回归树 五.回归树的剪枝 六.模型树 七.树回归与标准回归的比较 ...
- XGBoost参数中文翻译以及参数调优
XGBoost:参数解释:https://blog.csdn.net/zc02051126/article/details/46711047 机器学习系列(11)_Python中Gradient Bo ...
- http load 的使用以及参数解释
http load 的使用以及参数解释 1.参数含义 参数 全称 含义 -p -parallel 并发的用户进程数.-f -fetches ...
- /etc/sysctl.conf参数解释
/etc/sysctl.conf参数解释: fs.file max = 999999 #表示进程(例如一个worker进程)可能同时打开的最大句柄数,直接限制最大并发连接数 net.ipv4.tcp_ ...
- XGBoost参数
XGBoost参数 转自http://blog.csdn.net/zc02051126/article/details/46711047 在运行XGboost之前,必须设置三种类型成熟:general ...
- lcd参数解释及刷新率计算,LCD时序
一.LCD显示图像的过程如下: 其中,VSYNC和HSYNC是有宽度的,加上后如下: 参数解释: HBP(Horizontal Back Porch)水平后沿:在每行或每列的象素数据开始输出时要插入的 ...
- 机器学习--Xgboost调参
Xgboost参数 'booster':'gbtree', 'objective': 'multi:softmax', 多分类的问题 'num_class':10, 类别数,与 multisoftma ...
随机推荐
- Python2和Python3共存问题
前提条件:先准备一个新电脑 1.下载Python2和Python3的安装包,直接官网下载:https://www.python.org/download 2.配置环境变量,可以手动配置,也可以安装的时 ...
- ubuntu之路——day8.3 RMSprop
RMSprop: 全称为root mean square prop,提及这个算法就不得不提及上篇博文中的momentum算法 首先来看看momentum动量梯度下降法的过程: 在RMSprop中: C ...
- openssl从内存中读取私钥进行签名
麻痹的找了好久,真恶心! #include <stdio.h> #include <stdlib.h> #ifdef WIN32 #include <windows.h& ...
- Java IO系统--字符流
字符流:尽管字节流提供了处理任何类型输入/输出操作的足够功能,它们补鞥呢直接操作Unicode字符.字符流层次结构的顶层是Reader和Writer抽象类.类似于InputStream和OutputS ...
- ftp配置 Laravel上传文件到ftp服务器
listen=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask= dirmessage_enable=YES ...
- 沃顿商学院的MBA课程
沃顿商学院的MBA课程,分为必修课和选修课两部分 (一)必修课: 1.领导力:团队合作和领导力的基础 2.营销学:营销管理 3.微观经济学:微观经济基础 4.经济学:管理经济学的高级话题 5.统计学: ...
- 在Android Studio中下载Android SDK的两种方式(Android Studio3.0、windows)
方式一:网站下载:https://androidsdkmanager.azurewebsites.net/SDKPlatform 方式二.设置HTTP Proxy1. 打开Settings2. 点击H ...
- QQ第三方登录回调地址的问题
如题,维护以前的项目,发现原来QQ的第三方登录竟然失败了.回调地址的问题 原来是以前的规则变了.好吧,那就改,谁叫我不是改变规则的人. 中途浪费了点时间,项目很大,我一下也找不到项目里那个接口调用的, ...
- Qt编写数据可视化大屏界面电子看板13-基础版
一.前言 之前发布的Qt编写的可视化大屏电子看板系统,很多开发者比较感兴趣,也收到了很多反馈意见,纵观市面上的大屏系统,基本上都是B/S结构的web版本,需要在后台进行自定义配置模块,绑定数据源等,其 ...
- springboot 项目基本目录包结构
1.基本目录结构 controller service impl mapper utils domain config interceoter(拦截器) dto