Caret ‘train’ function repeats same fold with tuneLength when it’s greater than 1

  Kiến thức lập trình
train_control_scaled_xgbt <- trainControl(method = "repeatedcv",
                                          number = 10,
                                          repeats = 3,
                                          search = "random",
                                          verboseIter = TRUE,
                                          savePredictions = "final",
                                          returnResamp = "all")

model_test_3_scaled_xgbt_2 <- train(HC50.exp ~ .,
                                    data = train_data_3_scaled_xgbt,
                                    method = "xgbTree",
                                    trControl = train_control_scaled_xgbt,
                                    tuneLength = 50)

I’m using the caret package to perform hyperparameter tuning with repeated ten-fold cv for an xgboost model. When I set tuneLength to 1, everything works fine. However, when I increase tuneLength to a value greater than 1, the train function seems to repeatedly process the same fold and iteration.

  • Fold01.Rep1: eta=0.06318, max_depth=10, gamma=1.470841, colsample_bytree=0.5213, min_child_weight= 1, subsample=0.3305, nrounds=179
  • Fold01.Rep1: eta=0.06318, max_depth=10, gamma=1.470841, colsample_bytree=0.5213, min_child_weight= 1, subsample=0.3305, nrounds=179
  • Fold01.Rep1: eta=0.02120, max_depth= 2, gamma=3.580570, colsample_bytree=0.6624, min_child_weight= 1, subsample=0.9408, nrounds=526
  • Fold01.Rep1: eta=0.02120, max_depth= 2, gamma=3.580570, colsample_bytree=0.6624, min_child_weight= 1, subsample=0.9408, nrounds=526
  • Fold01.Rep1: eta=0.59964, max_depth=10, gamma=6.733325, colsample_bytree=0.5350, min_child_weight= 7, subsample=0.7565, nrounds=195

I tried setting the seed up and removing it, the second attemp worked for 10 cross-validations, but after that I couldn’t reproduce it.

New contributor

Joanna Kwiatka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT