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

Allow explicit specification of strata = NULL for grouped resampling #486

Merged
merged 1 commit into from
May 22, 2024

Conversation

hfrick
Copy link
Member

@hfrick hfrick commented May 22, 2024

closes #485

library(rsample)

set.seed(11)
rs1 <- group_vfold_cv(warpbreaks, "tension")

rs1 <- group_vfold_cv(warpbreaks, "tension", strata = NULL)

Created on 2024-05-22 with reprex v2.1.0

@hfrick hfrick requested a review from simonpcouch May 22, 2024 13:41
Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does the trick!

Is there a reason why this change is in check_grouped_strata() rather than just changing the condition in:

rsample/R/vfold.R

Lines 220 to 222 in c82c2a2

if (!missing(strata)) {
strata <- check_grouped_strata({{ group }}, {{ strata }}, pool, data)
}

to if (!is.null(strata))?

@hfrick
Copy link
Member Author

hfrick commented May 22, 2024

yeah... just doing that switch breaks being able to supply an unquote name for strata. I think it would need to be evaluated for this condition but unevaluated for check_grouped_strata() and that looked like the worse effort/effect ratio than what I did there.

I have since noticed that I was not alone in going down this route: #100

If we're touching this, we should do it across rsample.

@hfrick hfrick merged commit ce295aa into main May 22, 2024
12 checks passed
@hfrick hfrick deleted the grouping-stata-null branch May 22, 2024 19:05
Copy link

github-actions bot commented Jun 7, 2024

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.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grouped resampling breaks with non-missing strata = NULL
2 participants