I am trying to use the recursive feature elimination method using "xgbtree" as method. However I always encounter some error.
This is my code:
control <- rfeControl(functions = caretFuncs,
method = "repeatedcv", # repeated cv
repeats = 5, # number of repeats
number = 10) # number of folds
result_rfe1 <- rfe(x_train, y_train,
sizes = c(1:9),
rfeControl = control,
method="xgbTree")
If I use:
x_train <- data.matrix(x_train)
x_train <- xgb.DMatrix(x_train),
I have the error Error in { : task 1 failed - "unused argument (drop = FALSE)" and I have already downgraded the caret package and it did not work.
If I don't use xgb.DMatrix and use this:
x_train <- x[ inTrain, ],
the code runs but this is the output:
Something is wrong; all the RMSE metric values are missing:
RMSE Rsquared MAE
Min. : NA Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA Median : NA
Mean :NaN Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA Max. : NA
NA's :108 NA's :108 NA's :108
I do have some factor variballes, but I have tried to do the same RFE with random forest and it was not a problem. Any ideas on what can be wrong?
I already tried to downgrade the caret package but it did not work.