Sean CAI
Sean CAI

Reputation: 121

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.

Upvotes: 12

Views: 13414

Answers (1)

missuse
missuse

Reputation: 19756

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)

The current warning means xgboost is changing the name of an argument, but caret is still supplying the old name. Currently it works but with new xgboost versions the argument will be completely replaced, if carets function code is not updated by then the warning will be replaced by an error.

Upvotes: 12

Related Questions