Skip to content
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

Feature selection and formula update #9

Open
AlbertoImg opened this issue Jan 21, 2024 · 0 comments
Open

Feature selection and formula update #9

AlbertoImg opened this issue Jan 21, 2024 · 0 comments

Comments

@AlbertoImg
Copy link

I would like to know whether you know how to update the formula used in a workflow object during the fitting step, after a feature selection (FS) pre-processing step was performed.
The current issues is that when running the fit function I get "Error in eval(predvars, data, env) : object 'Var1' not found". It happens since the FS extracted that predictor, but the formula still considered it.
I had to add the formula using add_model, since I am working with a linear mixed effect, and so far I could not find a way to set the random effects ("ID") in a recipe object.

Case example:

predictors_list <- c("Var1", "Var2")
recipe <- recipe(dataset)%>% ... %>% step_select_boruta(all_predictors(), outcome = "Disease")

recipe <-
recipe %>% add_role("ID", new_role = "predictor")
mixed_effects_formula <- as.formula(
paste(
"Disease ~ ",
paste(c(predictors_list, "(1|ID)"), collapse = " + ")
)
)
wflow <- workflow() %>%
add_recipe(recipe) %>%
add_model(model, formula = mixed_effects_formula)

fitted_model <-
fit(
wflow,
data = data_train
)
"Error in eval(predvars, data, env) : object 'Var1' not found"

Thanks in advance
Best
Alberto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant