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
selecting no variables in recipes selections in v0.1.15 #603
Comments
Hi, I was checking out the fully supported tidyselect functionality, and I was wondering if the behavior changed when a logical expression selects no columns. Before this version, it would error out when prepped, but in 0.1.15, it appears that it now will prep and with no changes occurring in the step if no columns are selected. Is this correct? Thank you! |
Can you give an example? |
I think this produced an error in earlier recipes versions, and now it seems to handle the no-selection case pretty well now. > library(recipes)
> rec <-
+ recipe(as.formula("~."), data = mtcars) %>%
+ step_dummy(all_nominal()) %>%
+ prep()
> rec
Data Recipe
Inputs:
role #variables
predictor 11
Training data contained 32 data points and no missing data.
Operations:
Dummy variables were *not* created since no columns were selected. [trained] |
So I'm pretty sure that it depends on the step. We have not made a global change so that any step is skipped if nothing is selected. |
That step in particular always worked fine with empty selections New recipes (0.1.15) library(recipes)
rec <- recipe(mpg ~ ., mtcars)
rec <- step_dummy(rec, starts_with("foobar"))
prep(rec)
#> Data Recipe
#>
#> Inputs:
#>
#> role #variables
#> outcome 1
#> predictor 10
#>
#> Training data contained 32 data points and no missing data.
#>
#> Operations:
#>
#> Dummy variables were *not* created since no columns were selected. [trained] Old recipes (0.1.14) library(recipes)
rec <- recipe(mpg ~ ., mtcars)
rec <- step_dummy(rec, all_nominal())
prep(rec)
#> Data Recipe
#>
#> Inputs:
#>
#> role #variables
#> outcome 1
#> predictor 10
#>
#> Training data contained 32 data points and no missing data.
#>
#> Operations:
#>
#> Dummy variables were *not* created since no columns were selected. [trained] However, it seems I may have inadvertently changed this behavior with other steps when I did the tidyselect updates. We can revert it back, or keep this new behavior, but we should probably add some tests either way. New recipes (0.1.15) library(recipes)
rec <- recipe(mpg ~ ., mtcars)
rec <- step_center(rec, starts_with("foobar"))
prep(rec)
#> Data Recipe
#>
#> Inputs:
#>
#> role #variables
#> outcome 1
#> predictor 10
#>
#> Training data contained 32 data points and no missing data.
#>
#> Operations:
#>
#> Centering for <none> [trained] Old recipes (0.1.14) library(recipes)
rec <- recipe(mpg ~ ., mtcars)
rec <- step_center(rec, starts_with("foobar"))
prep(rec)
#> Error: No variables or terms were selected. Created on 2020-11-13 by the reprex package (v0.3.0.9001) |
@DavisVaughan , I'm glad to know that it wasn't just my imagination! I would say that I strongly prefer the new behavior where an error does NOT occur. It makes the recipe more dynamic & reusable on different datasets. It would helpful if the selections doc makes note of this behavior. https://github.com/tidymodels/recipes/blob/master/R/selections.R Also, this line in the doc is out of date: Additionally, the tidyselect domain specific |
That is specifically about |
Bigger picture, related to #531 |
Closed in #813 🎉 |
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. |
No description provided.
The text was updated successfully, but these errors were encountered: