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

Double intercept when used in a workflow with a formula as preprocessor #1032

Closed
hfrick opened this issue Dec 1, 2023 · 1 comment · Fixed by #1033
Closed

Double intercept when used in a workflow with a formula as preprocessor #1032

hfrick opened this issue Dec 1, 2023 · 1 comment · Fixed by #1033
Labels
bug an unexpected problem or unintended behavior

Comments

@hfrick
Copy link
Member

hfrick commented Dec 1, 2023

Two paths through parsnip's interface matrix (formula/matrix) can produce a double intercept when used in a workflow with a formula as the preprocessor.

This is the root cause for tidymodels/censored#272 and tidymodels/workflows#210. Opening the issue here because parsnip is the place to fix this.

library(workflows)
library(parsnip)

# form_xy()
workflow() %>%
  add_formula(mpg ~ cyl + disp + hp) %>%
  add_model(linear_reg(penalty = 0.1, engine = "glmnet"), formula = mpg ~ .) %>%
  fit(data = mtcars) %>%
  extract_fit_engine() %>%
  coef() %>%
  rownames()
#> [1] "(Intercept)"   "`(Intercept)`" "cyl"           "disp"         
#> [5] "hp"

# form_form()
workflow() %>%
  add_formula(mpg ~ cyl + disp + hp) %>%
  add_model(linear_reg(engine = "lm"), formula = mpg ~ .) %>%
  fit(data = mtcars) %>%
  extract_fit_engine() %>%
  coef() %>%
  names()
#> [1] "(Intercept)"   "`(Intercept)`" "cyl"           "disp"         
#> [5] "hp"

Created on 2023-12-01 with reprex v2.0.2

@hfrick hfrick added the bug an unexpected problem or unintended behavior label Dec 1, 2023
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant