梯度提升程序 (xgboost) 中如何使用参数 "weight" (DMatrix)?

How is the parameter "weight" (DMatrix) used in the gradient boosting procedure (xgboost)?

在 xgboost 中,可以为 DMatrix 设置参数 weight。这显然是一个权重列表,其中每个值都是相应样本的权重。 我找不到关于这些权重在梯度提升过程中实际如何使用的任何信息。它们与 eta 相关吗?

例如,如果我将所有样本的 weight 设置为 0.3 并将 eta 设置为 1,这是否与将 eta 设置为 0.3 和 weight 到 1?

正如您所指出的,

xgboost 允许在 DMatrix 的构建过程中进行加权。这个权重直接与实例相关联,并在整个训练过程中随实例移动。因此,它包含在梯度和粗麻布的计算中, 并直接影响 xgboost 模型的分割点和训练。

参见 here and here

Instance Weight File

XGBoost supports providing each instance an weight to differentiate the importance of instances. For example, if we provide an instance weight file for the "train.txt" file in the example as below:

train.txt.weight

1

0.5

0.5

1

0.5

It means that XGBoost will emphasize more on the first and fourth instance, that is to say positive instances while training. The configuration is similar to configuring the group information. If the instance file name is "xxx", XGBoost will check whether there is a file named "xxx.weight" in the same directory and if there is, will use the weights while training models.

eta

很不一样

eta 简单地告诉 xgboost 将最后一棵树训练到集成中的混合程度。衡量集成在每次迭代中的贪婪程度。

For example, if I would set weight to 0.3 for all samples and eta to 1, would this be the same as setting eta to 0.3 and weight to 1?

  • 所有实例的常数 weight 为 1 是默认值,因此将其更改为所有实例的常数 .3 仍然是相等的权重,因此这应该不会影响东西太多了。但是,将 eta 从 .3 设置为 1,会使训练更具攻击性。

weight in xgboost's DMatrix is the only correct way to enter exposure variable(例如保单期限)对于泊松分布的目标,例如保险索赔频率(即 'objective': 'count:poisson' 时)。

更多信息

那么错误的做法有哪些呢?与 Stack Exchange 上的回复相反,base_marginset_base_margin。我将所有这三个选项与 GLM 的 sample_weight(由 PoissonRegressorfit 方法公开)进行了基准测试,只有 weight 产生了类似的无偏模型(从实际与预测中可以看出个别特征的图)。更不用说早期停止指标(泊松负对数似然性或 RMSE)通过切换到 weight(下降到比 GLM 提高的水平)得到显着改善(更低)。