我正在尝试使用R中的插入符号包调整参数,但得到
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"
)
答案 0 :(得分:7)
问题在于你的xgb_grid_1。如果删除行eta,它将起作用。
xgboost和插入符号的标准调整选项是“nrounds”,“lambda”和“alpha”。不是eta。使用modelLookup函数查看可用的模型参数。如果你也想使用eta,你必须创建自己的插入符号模型,以便在调优中使用这个额外的参数。
modelLookup("xgbLinear")
model parameter label forReg forClass probModel
1 xgbLinear nrounds # Boosting Iterations TRUE TRUE TRUE
2 xgbLinear lambda L2 Regularization TRUE TRUE TRUE
3 xgbLinear alpha L2 Regularization TRUE TRUE TRUE