如何参数" weight" (DMatrix)用于梯度增强程序(xgboost)?

时间:2016-03-14 09:20:33

标签: xgboost

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

例如,如果我将所有样本的eta设置为0.3,将eta设置为1,这与将weight设置为0.3和Reading package lists... Done Building dependency tree Reading state information... Done Building data structures... Done Building data structures... Done Shiny Server Shiny Server is a server program from RStudio, Inc. that makes Shiny applications available over the web. Shiny is a web application framework for the R statistical computation language. Wollen Sie das Software-Paket installieren? [j/N]:j Vormals nicht ausgewähltes Paket shiny-server wird gewählt. (Lese Datenbank ... 61026 Dateien und Verzeichnisse sind derzeit installiert.) Vorbereitung zum Entpacken von shiny-server-1.4.2.786-amd64.deb ... Entpacken von shiny-server (1.4.2.786) ... shiny-server (1.4.2.786) wird eingerichtet ... Creating user shiny cat: /proc/1/comm: Datei oder Verzeichnis nicht gefunden /var/lib/dpkg/info/shiny-server.postinst: 73: test: =: unexpected operator grep: /etc/init/shiny-server.conf: Datei oder Verzeichnis nicht gefunden Adding LANG to /etc/init.d/shiny-server, setting to de_AT.UTF-8 设置为相同1?

2 个答案:

答案 0 :(得分:18)

正如您所指出的,

xgboost允许在构建DMatrix期间进行加权。这个重量与实例直接相关,并在整个训练过程中随之传播。因此,包含在梯度和赫斯的计算中,并直接影响xgboost模型的分裂点和跟踪。

请参阅herehere

  

实例权重文件

     

XGBoost支持为每个实例提供一个权重来区分   实例的重要性。例如,如果我们提供实例   示例中“train.txt”文件的权重文件如下:

     

train.txt.weight

     

1

     

0.5

     

0.5

     

1

     

0.5

     

这意味着XGBoost会更多地强调第一和第四个实例,也就是说训练时的正面实例。该   配置类似于配置组信息。如果   实例文件名是“xxx”,XGBoost会检查是否有   在同一目录中名为“xxx.weight”的文件,如果有,将会   在训练模型时使用权重。

eta

完全不同

eta只是告诉xgboost最后一棵树在整体中训练的混合程度。衡量每次迭代时整体的贪婪程度。

  

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

  • 对于所有实例,常量weight为1是默认值,因此对于所有实例,将其更改为.3的常量仍将是相等的权重,因此这不会对事物造成太大影响。但是,将eta从.3设置为1会使培训更具侵略性。

答案 1 :(得分:0)

xgboost's DMatrix 中的

weight 是为泊松分布目标输入 exposure variable(例如保险单持续时间)的唯一正确方法,例如保险索赔频率(即当 'objective': 'count:poisson' 时)。

更多信息

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