我正在尝试使用 R 中的 caret 包调整参数,但得到一个
Error in train.default(x = as.matrix(df_train %>% select(-c(Response, :
The tuning parameter grid should have columns nrounds, lambda, alpha
每当我尝试训练模型时,即使存在 nrounds、lambda 和 alpha 列。
library(caret)
library(xgboost)
library(readr)
library(dplyr)
library(tidyr)
xgb_grid_1 <- expand.grid(
nrounds= 2400,
eta=c(0.01,0.001,0.0001),
lambda = 1,
alpha =0
)
xgb_trcontrol <- trainControl(
method="cv",
number = 5,
verboseIter = TRUE,
returnData=FALSE,
returnResamp = "all",
allowParallel = TRUE,
)
xgb_train_1 <- train(
x = as.matrix(df_train %>% select(-c(Response, Id))),
y= df_train$Response,
trControl = xgb_trcontrol,
tuneGrid = xgb_grid_1,
method="xgbLinear"
)