В версии> = 6.0-81 из caret
сообщение об ошибке для этого типа случая более ясно.Например, если учесть, что в сетку настройки вводится mtry
, когда mtry
не является параметром для данного метода.
В caret
<6.0-81 произойдет следующая ошибка: </p>
# Error: The tuning parameter grid should have columns mtry
В caret
> = 6.0-81 произойдет следующая ошибка:
# Error: The tuning parameter grid should not have columns mtry
Представляет собой оригинальное непонятное сообщение об ошибке
А вот воспроизводимоепример, демонстрирующий улучшенное сообщение об ошибке.
caret <6.0-81 </h2> library(caret)
getNamespaceVersion("caret")
## version
## "6.0-80"
mtry <- round(sqrt(18), 0)
gbmGrid <- expand.grid(
interaction.depth = c(1, 2, 3, 4, 5, 6)
, n.trees = seq(10, 10000, by = 100)
, shrinkage = 0.01
, n.minobsinnode = c(5, 10, 20, 30)
, distribution = 'gaussian'
, method = 'gbm'
, mtry = mtry
)
fitControl <- trainControl(
method = "repeatedcv"
, number = 2
, repeats = 3
)
gbmFit1 <- train(
Species ~ Sepal.Length + Sepal.Width
, data = iris
, trControl = fitControl
, tuneGrid = gbmGrid
, verbose = FALSE
)
# Error: The tuning parameter grid should have columns mtry
caret> = 6.0-81
library(caret)
getNamespaceVersion("caret")
## version
## "6.0-81"
mtry <- round(sqrt(18), 0)
gbmGrid <- expand.grid(
interaction.depth = c(1, 2, 3, 4, 5, 6)
, n.trees = seq(10, 10000, by = 100)
, shrinkage = 0.01
, n.minobsinnode = c(5, 10, 20, 30)
, distribution = 'gaussian'
, method = 'gbm'
, mtry = mtry
)
fitControl <- trainControl(
method = "repeatedcv"
, number = 2
, repeats = 3
)
gbmFit1 <- train(
Species ~ Sepal.Length + Sepal.Width
, data = iris
, trControl = fitControl
, tuneGrid = gbmGrid
, verbose = FALSE
)
# Error: The tuning parameter grid should not have columns mtry
Для получения дополнительной информации см. GitHubпроблема, которая описала и затем исправила это поведение: https://github.com/topepo/caret/issues/955