'CARET xgbtree warning: `ntree_limit` is deprecated, use `iteration_range` instead

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")

Hi, when I was trying to run the above code, the following warnings are shown in the R console. Does anyone know how to get rid of it? I have tried suppressWarnings() , warning = FALSE on the chunk setting, and it is still there.

thx!!

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.


Solution 1:[1]

To get rid of xgboost warnings you can set verbosity = 0 which will be passed on by caret::train to the xgboost call:

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 missuse