cimentadaj / tidyflow

A simplified and fresh workflow for doing machine learning with tidymodels
https://cimentadaj.github.io/tidyflow/
Other
8 stars 0 forks source link

Cant replace model in fitted tidyflow #4

Closed cimentadaj closed 4 years ago

cimentadaj commented 4 years ago
library(parsnip)
library(tidyflow)

# Define two competing model:
lm_model <- set_engine(linear_reg(), "lm")
regularized_model <- set_engine(lm_model, "glmnet")

# Define a minimal tidyflow: data + formula + model
wf <-
  mtcars %>%
  tidyflow() %>%
  plug_formula(mpg ~ .) %>% 
  plug_model(lm_model) %>%
  fit()

reg_fitted <-
  wf %>%
  replace_model(regularized_model) %>%
  fit()
#> Error: `data` must be a data.frame or a matrix, not a list.