gbm 无法识别调整参数网格
gbm not recognising tuning parameter grid
脚本:
library(caret)
library(gbm)
formula <- price ~ carat + depth + table + x + y + z
mtryGrid <- expand.grid(interaction.depth = seq(1, 7, by = 2),
n.trees = seq(100, 1000, by = 50),
n.minobsinnode = 10,
verbose = FALSE,
shrinkage = c(0.01, 0.1))
set.seed(100)
gbm_model <- train(formula,
data = diamonds,
method = "gbm",
tuneGrid = mtryGrid,
trControl = trainControl(method = "cv"))
给出错误:
Error: The tuning parameter grid should have columns n.trees,
interaction.depth, shrinkage, n.minobsinnode
虽然 mtryGrid 似乎有所有四个必需的列
我使用的是 R3.5.1,插入符号 6.0-80,gbm 2.1.3
所以你不应该把verbose=FALSE
放在expand.grid
中。该错误清楚地表明它只能在 expand.grid
中使用 n.trees、interaction.depth 等。删除 verbose=FALSE
得到了方程的结果。
希望对您有所帮助
因此以下内容适用于我的系统。要抑制打印,请在 train 函数中使用 verbose=FALSE
。
formula <- price ~ carat + depth + table + x + y + z
mtryGrid <- expand.grid(interaction.depth = seq(1, 7, by = 2),
n.trees = seq(100, 1000, by = 50),
n.minobsinnode = 10,
shrinkage = c(0.01, 0.1))
expand.grid(n.trees=c(10,20,60),shrinkage=c(0.05,0.1,0.5),n.minobsinnode = c(3,5),interaction.depth=c(3,5))
set.seed(100)
gbm_model <- train(formula,
data = diamonds,
method = "gbm",
tuneGrid = mtryGrid,
trControl = trainControl(method = "cv"), verbose=FALSE)
脚本:
library(caret)
library(gbm)
formula <- price ~ carat + depth + table + x + y + z
mtryGrid <- expand.grid(interaction.depth = seq(1, 7, by = 2),
n.trees = seq(100, 1000, by = 50),
n.minobsinnode = 10,
verbose = FALSE,
shrinkage = c(0.01, 0.1))
set.seed(100)
gbm_model <- train(formula,
data = diamonds,
method = "gbm",
tuneGrid = mtryGrid,
trControl = trainControl(method = "cv"))
给出错误:
Error: The tuning parameter grid should have columns n.trees, interaction.depth, shrinkage, n.minobsinnode
虽然 mtryGrid 似乎有所有四个必需的列
我使用的是 R3.5.1,插入符号 6.0-80,gbm 2.1.3
所以你不应该把verbose=FALSE
放在expand.grid
中。该错误清楚地表明它只能在 expand.grid
中使用 n.trees、interaction.depth 等。删除 verbose=FALSE
得到了方程的结果。
希望对您有所帮助
因此以下内容适用于我的系统。要抑制打印,请在 train 函数中使用 verbose=FALSE
。
formula <- price ~ carat + depth + table + x + y + z
mtryGrid <- expand.grid(interaction.depth = seq(1, 7, by = 2),
n.trees = seq(100, 1000, by = 50),
n.minobsinnode = 10,
shrinkage = c(0.01, 0.1))
expand.grid(n.trees=c(10,20,60),shrinkage=c(0.05,0.1,0.5),n.minobsinnode = c(3,5),interaction.depth=c(3,5))
set.seed(100)
gbm_model <- train(formula,
data = diamonds,
method = "gbm",
tuneGrid = mtryGrid,
trControl = trainControl(method = "cv"), verbose=FALSE)