我一直在使用食谱将其插入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)
答案 0 :(得分:0)
quadratic = NULL应该是quadratic_model = NULL