我一直在使用食谱来输入caret::train
,进展顺利,但现在我尝试了一些 step_transforms,我收到了错误:
Error in resamples.default(model_list) :
There are different numbers of resamples in each model
当我比较有和没有转换的模型时。相同的代码step_centre
和step_scale
工作正常。
library(caret)
library(tidyverse)
library(tidymodels)
formula <- price ~ carat
model_recipe <- recipe(formula, data = diamonds)
quadratic_model_recipe <- recipe(formula, data = diamonds) %>%
step_poly(all_predictors())
model_list <- list(
linear_model = NULL,
quadratic = NULL
)
model_list$linear_model <-
model_recipe %>% train(
data = diamonds,
method = "lm",
trControl = trainControl(method = "cv"))
model_list$quadratic_model <-
quadratic_model_recipe %>% train(
data = diamonds,
method = "lm",
trControl = trainControl(method = "cv"))
resamp <- resamples(model_list)