【问题标题】:How to instruct xgboost in caret to use mlogloss for optimization如何在插入符号中指示 xgboost 使用 mlogloss 进行优化
【发布时间】:2016-05-26 20:07:50
【问题描述】:

我有一个多类问题:例如,我们可以获取数据集mtcars 数据集,并且我们想要预测气缸数cyl

data(mtcars)

我想使用 xgboost 并使用 caret 包安装它。为此,我使用

为超参数创建网格
xgb_grid_param = expand.grid(
  nrounds = 1000,
  eta = c(0.01, 0.001, 0.0001),
  max_depth = c(2, 4),
  gamma = 0,
  colsample_bytree =1,
  min_child_weight =1  
)

我可以将训练控制参数创建为

xgb_tr_ctrl = trainControl(
  method = "cv",
  number = 5,
  repeats =2,
  verboseIter = TRUE,
  returnData = FALSE,
  returnResamp = "all",
  allowParallel = TRUE  

)

当我尝试在caret 中运行train 函数时,使用:

model <- train(factor(cyl)~., data = mtcars, method = "xgbTree",
         trControl = xgb_grid_param, tuneGrid=xgb_grid_param)

我得到错误::

 Error in trControl$classProbs && any(classLevels !=  make.names(classLevels)) :
  invalid 'x' type in 'x && y'

如何修复此错误以及如何指示 xgbTree 使用 mlogloss 优化学习。

【问题讨论】:

    标签: r parameters classification xgboost


    【解决方案1】:

    对于另一种方法,我可以通过将标签属性设置为数据框/矩阵的最后一列来解决“'x && y'中的'x'类型无效”。

    【讨论】:

      猜你喜欢
      • 2019-11-24
      • 1970-01-01
      • 2014-08-19
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      • 2023-03-31
      相关资源
      最近更新 更多