0

So far I built many classification models using the "caret" package. This library allows me to find the best parameters for XGBoost by using expand.grid and trying all the possible combinations of some parameters as shown in the example below.



     trControl = trainControl(
          method = 'cv',
          number = 3,
          returnData=F,
          classProbs = TRUE,
          verboseIter = TRUE,
          allowParallel = TRUE)

        tuneGridXGB <- expand.grid(
          nrounds=c(10, 50, 100, 200, 350, 500),
          max_depth = c(2,4),
          eta = c(0.005, 0.01, 0.05, 0.1),
          gamma = c(0,2,4),
          colsample_bytree = c(0.75),
          subsample = c(0.50),
          min_child_weight = c(0,2,4))

        xgbmod_classif_bin <- train(
          x=eg_Train_mat,
          y= y_train_target,
          method = "xgbTree",
          metric = "auc",
          reg_lambda=0.7,
          scale_pos_weight=1.6,
          nthread = 4,
          trControl = trControl,
          tuneGrid = tuneGridXGB,
          verbose=T)

For the first time I have a multiclass classification problem (with 9 classes) to deal with, but I don't seem to be able to use anything like "multi:softprob" (as I would do with the xgboost package - see below).


    param=list(objective="multi:softprob",   
               num_class=9,
               eta=0.005,
               max.depth=4,
               min_child_weight=2,
               gamma=6,
               eval_metric ="merror",
               nthread=4,
               booster = "gbtree",
               lambda=1.8,
               subssample=0.8,
               alpha=6,
               colsample_bytree=0.5,
               scale_pos_weight=1.6,
               verbosity=3
    )


    bst=xgboost(params = param, 
                data = eg_Train_mat, 
                nrounds = 15)

Any idea of how to try many parameters using a grid, possibly using the caret package, for a multiclass classification problem? Thanks

user11428
  • 115
  • 5
  • Please provide a minimal reproducible example (https://stackoverflow.com/q/5963269/1320535) with some data showing what exactly you'd like to do. – Julius Vainora Jan 11 '19 at 14:54
  • I just edited my post. Hope now it's clearer :) – user11428 Jan 11 '19 at 15:00
  • It's clearer, but still the example isn't really minimal (perhaps one parameter would be enough?) and more importantly there is no toy data for us to work with. – Julius Vainora Jan 11 '19 at 15:02

0 Answers0