【问题标题】:Error : The tuning parameter grid should have columns mtry, SVM Regression错误:调整参数网格应该有列 mtry、SVM 回归
【发布时间】:2020-07-21 14:51:04
【问题描述】:

我正在尝试使用 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

【问题讨论】:

    标签: r regression svm r-caret


    【解决方案1】:

    您使用的是随机森林,而不是支持向量机。您收到错误,因为您只能在 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

    【讨论】:

      猜你喜欢
      • 2018-06-25
      • 2019-03-20
      • 1970-01-01
      • 1970-01-01
      • 2018-06-10
      • 1970-01-01
      • 2021-03-23
      • 2016-11-20
      • 2018-05-29
      相关资源
      最近更新 更多