Параметр Tuning Xgboost в R - PullRequest
0 голосов
/ 03 марта 2020

Я использую grid для xgboost и получаю сообщение об ошибке

Ошибка в as.matrix (cv.res) [, 3]: нижний индекс вне пределов. Дополнительно: Предупреждающее сообщение: 'early.stop.round ' устарел. Вместо этого используйте 'early_stopping_rounds'. Смотрите help («Устаревший») и help («Устаревший xgboost»). фрагмент кода

Был бы признателен, если бы кто-то мог решить меня с ошибкой и также мог бы предоставить лучший способ настройки параметра с кодом, у меня 11 миллионов строк и 74 столбца, и это займет много время или много дней для мелодий, я был бы признателен, если бы кто-то мог предоставить другую альтернативу, кроме этого подхода в R

X_Train <- as(X_train, "dgCMatrix")


GS_LogLoss = data.frame("Rounds" = numeric(), 
                        "Depth" = numeric(),
                        "r_sample" = numeric(),
                        "c_sample" = numeric(), 
                        "minLogLoss" = numeric(),
                        "best_round" = numeric())

for (rounds in seq(50,100, 25)) {
  
  for (depth in c(4, 6, 8, 10)) {
    
    for (r_sample in c(0.5, 0.75, 1)) {
      
      for (c_sample in c(0.4, 0.6, 0.8, 1)) {
        
        for (imb_scale_pos_weight in c(5, 10, 15, 20, 25))	{
          
          for (wt_gamma in c(5, 7, 10)) {
            
            for (wt_max_delta_step in c(5,7,10)) {
              
              for (wt_min_child_weight in c(5,7,10,15))	{
                
                
                set.seed(1024)
                eta_val = 2 / rounds
                cv.res = xgb.cv(data = X_Train, nfold = 2, label = y_train, 
                                nrounds = rounds, 
                                eta = eta_val, 
                                max_depth = depth,
                                subsample = r_sample, 
                                colsample_bytree = c_sample,
                                early.stop.round = 0.5*rounds,
                                scale_pos_weight= imb_scale_pos_weight,
                                max_delta_step = wt_max_delta_step,
                                gamma = wt_gamma,
                                objective='binary:logistic', 
                                eval_metric = 'auc',
                                verbose = FALSE)
                
                print(paste(rounds, depth, r_sample, c_sample, min(as.matrix(cv.res)[,3]) ))
                GS_LogLoss[nrow(GS_LogLoss)+1, ] = c(rounds, 
                                                     depth, 
                                                     r_sample, 
                                                     c_sample, 
                                                     min(as.matrix(cv.res)[,3]), 
                                                     which.min(as.matrix(cv.res)[,3]))
                
              }
            }
          }
        }	
      }
    }
  }	
}	
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...