XGBoost 参数说明

XGBoost使用key-value字典的方式存储参数:html


params = {
    'booster': 'gbtree',
    'objective': 'multi:softmax',  # 多分类的问题
    'num_class': 10,       # 类别数,与 multisoftmax 并用
    'gamma': 0.1,      # 用于控制是否后剪枝的参数,越大越保守,通常0.一、0.2这样子。
    'max_depth': 12,       # 构建树的深度,越大越容易过拟合
    'lambda': 2,          # 控制模型复杂度的权重值的L2正则化项参数,参数越大,模型越不容易过拟合。
    'subsample': 0.7,           # 随机采样训练样本
    'colsample_bytree': 0.7,       # 生成树时进行的列采样
    'min_child_weight': 3,
    'silent': 1,                   # 设置成1则没有运行信息输出,最好是设置为0.
    'eta': 0.007,                  # 如同窗习率
    'seed': 1000,
    'nthread': 4,                  # cpu 线程数
}

在运行XGboost以前,必须设置三种类型成熟:general parameters,booster parameters和task parameters:node

  • General parameters 
    该参数参数控制在提高(boosting)过程当中使用哪一种booster,经常使用的booster有树模型(tree)和线性模型(linear model)。git

  • Booster parameters 
    这取决于使用哪一种booster。算法

  • Task parameters 
    控制学习的场景,例如在回归问题中会使用不一样的参数控制排序。ide

————————————————————————
函数

  • booster [default=gbtree]学习

    有两中模型能够选择gbtree和gblinear。gbtree使用基于树的模型进行提高计算,gblinear使用线性模型进行提高计算。缺省值为gbtreeui

  • silent [default=0]lua

    取0时表示打印出运行时信息,取1时表示以缄默方式运行,不打印运行时信息。缺省值为0spa

  • nthread

    XGBoost运行时的线程数。缺省值是当前系统能够得到的最大线程数

  • num_pbuffer

    预测缓冲区大小,一般设置为训练实例的数目。缓冲用于保存最后一步提高的预测结果,无需人为设置。

  • num_feature

    Boosting过程当中用到的特征维数,设置为特征个数。XGBoost会自动设置,无需人为设置。


##  Parameters for Tree Booster

  • 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. 
    取值范围为:[0,∞]

  • max_depth [default=6] 
    数的最大深度。缺省值为6 
    取值范围为:[1,∞]

  • min_child_weight [default=1] 
    孩子节点中最小的样本权重和。若是一个叶子节点的样本权重和小于min_child_weight则拆分过程结束。在现行回归模型中,这个参数是指创建每一个模型所须要的最小样本数。该成熟越大算法越conservative 
    取值范围为:[0,∞]

  • max_delta_step [default=0] 
    咱们容许每一个树的权重被估计的值。若是它的值被设置为0,意味着没有约束;若是它被设置为一个正值,它可以使得更新的步骤更加保守。一般这个参数是没有必要的,可是若是在逻辑回归中类极其不平衡这时候他有可能会起到帮助做用。把它范围设置为1-10之间也许能控制更新。 
    取值范围为:[0,∞]

  • subsample [default=1] 
    用于训练模型的子样本占整个样本集合的比例。若是设置为0.5则意味着XGBoost将随机的从整个样本集合中随机的抽取出50%的子样本创建树模型,这可以防止过拟合。 
    取值范围为:(0,1]

  • colsample_bytree [default=1] 
    在创建树时对特征采样的比例。缺省值为1 
    取值范围为:(0,1]

##   Parameter for Linear Booster

  • lambda [default=0] 
    L2 正则的惩罚系数

  • alpha [default=0] 
    L1 正则的惩罚系数

  • lambda_bias 
    在偏置上的L2正则。缺省值为0(在L1上没有偏置项的正则,由于L1时偏置不重要)



##  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 ]

    • 全部实例的初始化预测分数,全局偏置;

    • 为了足够的迭代次数,改变这个值将不会有太大的影响。

  • eval_metric [ default according to objective ]

    • “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 #(wrongcases)#(allcases).

    • “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

    • 校验数据所须要的评价指标,不一样的目标函数将会有缺省的评价指标(rmse for regression, and error for classification, mean average precision for ranking)-

    • 用户能够添加多种评价指标,对于Python用户要以list传递参数对给程序,而不是map参数list参数不会覆盖’eval_metric’

    • 可供的选择以下:

  • seed [ default=0 ]

    • 随机数的种子。缺省值为0


refer  : https://www.cnblogs.com/timxgb/p/8231130.html

相关文章
相关标签/搜索