-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add reverse_splits #319
Add reverse_splits #319
Conversation
@@ -109,7 +109,7 @@ rset_reconstructable <- function(x, to) { | |||
test_data <- function() { | |||
data.frame( | |||
x = 1:50, | |||
y = rep(c(1, 2), each = 25), | |||
y = rep(seq.int(10), each = 5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only having two groups here made group_mc_cv()
error due to having 0 data in the assessment set. I also did a version of this in #316 to deal with the same issue there (to get both PRs to pass CI).
@mattwarkentin would you like to take a look at this? |
I made a couple minor comments but otherwise LGTM! Thanks for addressing this so quickly, @mikemahoney218. |
Oh, one more thought. Have you tested this function with an object from |
So this does currently error, though we could possibly provide a friendlier message than what's currently thrown: library(rsample)
permutations(mtcars, cyl)
#> # Permutation sampling
#> # Permuted columns: [cyl]
#> # A tibble: 25 × 2
#> splits id
#> <list> <chr>
#> 1 <split [32/0]> Permutations01
#> 2 <split [32/0]> Permutations02
#> 3 <split [32/0]> Permutations03
#> 4 <split [32/0]> Permutations04
#> 5 <split [32/0]> Permutations05
#> 6 <split [32/0]> Permutations06
#> 7 <split [32/0]> Permutations07
#> 8 <split [32/0]> Permutations08
#> 9 <split [32/0]> Permutations09
#> 10 <split [32/0]> Permutations10
#> # … with 15 more rows
permutations(mtcars, cyl) |>
reverse_splits()
#> Error in `rsplit()` at rsample/R/misc.R:23:2:
#> ! At least one row should be selected for the analysis set. Created on 2022-06-29 by the reprex package (v2.0.1) (Which, as a sidenote @juliasilge , |
Related: I am now seeing that the error thrown when calling library(rsample)
p <- permutations(mtcars, cyl)
assessment(p$splits[[1]])
#> Error in `as.data.frame()`:
#> ! There is no assessment data set for an `rsplit` object with class `rsplit`. It should read something like:
Or something along those lines... |
Opened #321 to track that one 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! 🙌
This pull request 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. |
This PR fixes #284 by adding a new utility function to "reverse" the analysis and assessment splits.
Created on 2022-06-29 by the reprex package (v2.0.1)