【问题标题】:R xgboost, problems with gamma regressionR xgboost,伽马回归问题
【发布时间】:2017-03-08 22:41:03
【问题描述】:

我正在玩 xgboost,有一些财务数据,并想尝试将伽马回归作为目标。

cvs <- xgb.cv(data = sparse_matrix, label = target, nfold = 10, nthread = 4, nround = 16, objective = "reg:gamma", metrics = list("mae"))

但这似乎比使用线性回归作为目标需要更长的时间。

并且还会抛出很多如下警告:

In foldVector[which(y == dimnames(numInClass)$y[i])] <- sample(seqVector) :
  number of items to replace is not a multiple of replacement length

此警告重复了大约 50 次。

发生了什么事?我不应该使用 reg:gamma 作为目标吗,因为 reg:linear 工作得很好,我只是在玩,只是想尝试各种目标

谁能指出为什么会出现这些警告?

【问题讨论】:

    标签: r xgboost


    【解决方案1】:

    我的回答有点晚,但可能对其他人有所帮助。我对reg:logistic 目标也有同样的问题,我解决它的方法是在xgb.cv 中设置stratified=FALSE

    根据 xgboost 文档,stratified 是一个 布尔值,指示折叠的抽样是否应按结果标签的值进行分层。

    【讨论】:

      【解决方案2】:

      我不知道我是否迟到了,但我遇到了类似的问题。这个问题确实有两个不同版本的 XGBoost。一个与 R 3.3.2 一起运行,另一个是 R 3.4.3 因此,与 R 3.4.3 兼容的 XGBoost 包中具有“reg:gamma”功能。 我安装了 R 3.4.3 版本,现在可以正常使用了。

      【讨论】:

        猜你喜欢
        • 2015-03-05
        • 1970-01-01
        • 1970-01-01
        • 2021-12-23
        • 2016-03-27
        • 1970-01-01
        • 2017-11-09
        • 1970-01-01
        • 2014-11-12
        相关资源
        最近更新 更多