Error : The tuning parameter grid should have columns mtry, SVM Regression
Error : The tuning parameter grid should have columns mtry, SVM Regression
我正在尝试使用 caret 包调整 SVM 回归模型。代码下方:
control <- trainControl(method="cv", number=5)
tunegrid <- expand.grid(.mtry=c(6:12), .ntree=c(500, 600, 700, 800, 900, 1000))
set.seed(2)
custom <- train(CRTOT_03~., data=train, method="rf", metric="rmse", tuneGrid=tunegrid, trControl=control)
summary(custom)
plot(custom)
我收到错误
Error : The tuning parameter grid should have columns mtry
您使用的是随机森林,而不是支持向量机。您收到错误消息,因为您只能在 caret
中随机森林的调整网格中设置 .mtry
ntree
参数是通过将 ntree
传递给 train
,例如
control <- trainControl(method="cv", number=5)
tunegrid <- expand.grid(.mtry = 6:12)
set.seed(2)
custom <- train(CRTOT_03~.,
data=train, method="rf",
metric="rmse",
tuneGrid=tunegrid,
ntree = 1000,
trControl=control)
ntree
直接传递给randomForest
我正在尝试使用 caret 包调整 SVM 回归模型。代码下方:
control <- trainControl(method="cv", number=5)
tunegrid <- expand.grid(.mtry=c(6:12), .ntree=c(500, 600, 700, 800, 900, 1000))
set.seed(2)
custom <- train(CRTOT_03~., data=train, method="rf", metric="rmse", tuneGrid=tunegrid, trControl=control)
summary(custom)
plot(custom)
我收到错误
Error : The tuning parameter grid should have columns mtry
您使用的是随机森林,而不是支持向量机。您收到错误消息,因为您只能在 caret
中随机森林的调整网格中设置 .mtry
ntree
参数是通过将 ntree
传递给 train
,例如
control <- trainControl(method="cv", number=5)
tunegrid <- expand.grid(.mtry = 6:12)
set.seed(2)
custom <- train(CRTOT_03~.,
data=train, method="rf",
metric="rmse",
tuneGrid=tunegrid,
ntree = 1000,
trControl=control)
ntree
直接传递给randomForest