2

I've been using recipes to pipe into caret::train, which has been going well, but now I've tried some step_transforms, I'm getting the error:

Error in resamples.default(model_list) : 
  There are different numbers of resamples in each model

when I compare models with and without the transformations. The same code with step_centre and step_scale works fine.

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)
divibisan
  • 11,659
  • 11
  • 40
  • 58
Isaiah
  • 2,091
  • 3
  • 19
  • 28

1 Answers1

0

quadratic = NULL should have been quadratic_model = NULL

Isaiah
  • 2,091
  • 3
  • 19
  • 28