CARET xgbtree 警告:`ntree_limit` 已弃用,请使用 `iteration_range` 代替

Sea*_*CAI 9 warnings r knitr r-caret xgboost

cv <- trainControl(
  method = "cv",
  number = 5,
  classProbs = TRUE,
  summaryFunction = prSummary,
  seeds = set.seed(123))

turn_grid_xgb <- expand.grid(
  eta = c(0.1,0.3,0.5),
  max_depth = 5,
  min_child_weight = 1,
  subsample = 0.8,
  colsample_bytree = 0.8,
  nrounds = (1:10)*200,
  gamma = 0)

set.seed(123)
suppressWarnings({
  xgb_1 <- train(label~., data = baked_train, 
             method = "xgbTree",
             tuneGrid = turn_grid_xgb,
             trControl = cv,
             verbose = FALSE,
             metric = "F")
Run Code Online (Sandbox Code Playgroud)

您好,当我尝试运行上面的代码时,R 控制台中显示以下警告。有谁知道如何摆脱它?我已经尝试过suppressWarnings()warning = FALSE在块设置上,它仍然存在。

谢谢!!

WARNING: amalgamation/../src/c_api/c_api.cc:718: `ntree_limit` is deprecated, use `iteration_range` instead.
[02:15:13] WARNING: amalgamation/../src/c_api/c_api.cc:718: `ntree_limit` is deprecated, use `iteration_range` instead.
[02:15:13] WARNING: amalgamation/../src/c_api/c_api.cc:718: `ntree_limit` is deprecated, use `iteration_range` instead.
Run Code Online (Sandbox Code Playgroud)

mis*_*use 7

要摆脱 xgboost 警告,您可以设置verbosity = 0将传递给caret::train调用xgboost的警告:

library(caret)
library(mlbench)
data(Sonar)


cv <- trainControl(
  method = "cv",
  number = 5,
  classProbs = TRUE,
  summaryFunction = prSummary,
  seeds = set.seed(123))

turn_grid_xgb <- expand.grid(
  eta = 0.1,
  max_depth = 5,
  min_child_weight = 1,
  subsample = 0.8,
  colsample_bytree = 0.8,
  nrounds = c(1,5)*200,
  gamma = 0)

set.seed(123)

xgb_1 <- train(Class~., data = Sonar, 
               method = "xgbTree",
               tuneGrid = turn_grid_xgb,
               trControl = cv,
               verbose = FALSE,
               metric = "F",
               verbosity = 0)
Run Code Online (Sandbox Code Playgroud)

当前警告意味着 xgboost 正在更改参数的名称,但插入符号仍然提供旧名称。目前它可以工作,但对于新的 xgboost 版本,参数将被完全替换,如果插入符号函数代码尚未更新,则警告将被错误替换。

  • 当前警告意味着 xgboost 正在更改参数的名称,但插入符仍然提供旧名称。目前它可以工作,但对于新的 xgboost 版本,参数将被完全替换,如果插入符号函数代码尚未更新,则警告将被错误替换。 (2认同)