{targets} is a package to manage the workflow. (https://wlandau.github.io/targets-manual/)
I tried to apply the {targets} for the tidymodels framework.
When I re-run target to get the coefficients of the final model, It returns null
_targets.R
library(targets)
options(tidyverse.quiet = TRUE)
tar_option_set(packages = c("tidyverse", "tidymodels"))
tar_pipeline(
tar_target(glmn_rec,
recipe(mpg ~ ., data = mtcars) %>%
step_normalize(all_predictors())),
tar_target(mod,
linear_reg(penalty = 0.1, mixture = 1) %>%
set_engine("glmnet")),
tar_target(glmn_wflow,
workflow() %>%
add_model(mod) %>%
add_recipe(glmn_rec)),
tar_target(glmn_fit,
glmn_wflow %>%
fit(data = mtcars)),
tar_target(coeff,
glmn_fit %>%
pull_workflow_fit() %>%
pluck("fit") %>%
coef(s = 0.1))
)
library(targets)
tar_make()
tar_read(coeff)
# edit the coef(s=0.1) -> coef(s=0.2) in the original _targets.R file
tar_target(coeff,
glmn_fit %>%
pull_workflow_fit() %>%
pluck("fit") %>%
coef(s = 0.2))
# re-run coeff target return NULL
tar_make()
tar_read(coeff)