I am trying to research my model with R using xgboost. The training model as a whole works well, but with a caret, this is a metric problem.
I tried to set the coefficient for the class column, the bit has not yet received the result.
My details
ID var1var2TARGET 1 5 0 1 2 4 3 1 3 4 2 0 4 3 1 0 5 2 4 1 6 1 2 1 7 5 3 1 8 4 1 0 9 4 1 0 10 2 4 1 11 5 5 1
For this I do
train <- read.csv() train.y <- train$TARGET train$TARGET <- NULL train$ID <- NULL train.y <- lapply(train.y, factor)
Then I prepare the model parameters
xgb_grid_1 = expand.grid( nrounds = 1000, eta = c(0.01, 0.001, 0.0001), max_depth = c(2, 4, 6, 8, 10), gamma = 1 ) # pack the training control parameters xgb_trcontrol_1 = trainControl( method = "cv", number = 5, verboseIter = TRUE, returnData = FALSE, returnResamp = "all", # save losses across all models classProbs = TRUE, # set to TRUE for AUC to be computed summaryFunction = twoClassSummary, allowParallel = TRUE )
And after all this, I call the train function
xgb_train_1 = train( x = train, y = train.y, trControl = xgb_trcontrol_1, tuneGrid = xgb_grid_1, method = "xgbTree" )
It gives me
Error in train.default(x = train, y = train.y, trControl = xgb_trcontrol_1, : Metric RMSE not applicable for classification models
Why?