-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More details of formula usage in mgcv engine docs when using workflow #770
Comments
A relevant Community post with reprex: https://community.rstudio.com/t/error-in-fit-xy-with-gam-model/143065 |
+1 |
Assume we have a response variable, Assume GAM formula is: gam_formula <- "outcome ~ ." |> as.formula() Then, you preprocess it through recipes with: data_recipe <- recipes::recipe(
formula = gam_formula,
data = data_train
) |>
recipes::step_dummy(prec_fac) |>
# Other Steps ...
# Train the recipe
data_recipe_prep <- data_recipe |>
recipes::prep(training = data_train)
# Apply to training data
data_train_prep <- data_recipe_prep |>
recipes::bake(new_data = NULL)
# Apply to test data
data_test_prep <- data_recipe_prep |>
recipes::bake(new_data = data_test) For things to work elsewhere, say in formula_alt = gam_formula |> terms.formula(data = data_train_prep) So, whenever we have categorical variables in the model formula, you would need to manually preprocess data and use the terms from that. This change of formulae in particular, is very confusing, and could potentially cause serious inconsistencies. Where do you use |
This may be a workflows or hardhat change rather than parsnip, but it might be worth looking out for indicative input in |
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
We need to include more details about using gam formula in the engine doc
gen_additive_mod(engien = "mgcv")
. The engine doc only shows model fitting examples when using gam formula infit()
directly. When using a workflow with recipes, the gam formula needs to be declared inadd_model
alongside with the model specThe text was updated successfully, but these errors were encountered: