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

Expose pool argument across resampling functions #229

Merged
merged 6 commits into from
Mar 18, 2021
Merged

Conversation

juliasilge
Copy link
Member

This PR closes #211 by exposing the pool argument to user-facing functions such as vfold_cv(), mc_cv(), and bootstraps().

library(tidyverse)
library(rsample)

df <- tibble(x = rnorm(60), label = rep(letters[1:12], each = 5))

mc_cv(df, v = 3, strata = label)
#> Warning: Too little data to stratify. Unstratified resampling
#> # Monte Carlo cross-validation (0.75/0.25) with 25 resamples  using stratification 
#> # A tibble: 25 x 2
#>    splits          id        
#>    <list>          <chr>     
#>  1 <split [45/15]> Resample01
#>  2 <split [45/15]> Resample02
#>  3 <split [45/15]> Resample03
#>  4 <split [45/15]> Resample04
#>  5 <split [45/15]> Resample05
#>  6 <split [45/15]> Resample06
#>  7 <split [45/15]> Resample07
#>  8 <split [45/15]> Resample08
#>  9 <split [45/15]> Resample09
#> 10 <split [45/15]> Resample10
#> # … with 15 more rows
mc_cv(df, v = 3, strata = label, pool = 0.05)
#> Warning: Stratifying groups that make up 5% of the data may be statistically risky.
#> Consider increasing `pool` to at least 0.1
#> # Monte Carlo cross-validation (0.75/0.25) with 25 resamples  using stratification 
#> # A tibble: 25 x 2
#>    splits          id        
#>    <list>          <chr>     
#>  1 <split [36/24]> Resample01
#>  2 <split [36/24]> Resample02
#>  3 <split [36/24]> Resample03
#>  4 <split [36/24]> Resample04
#>  5 <split [36/24]> Resample05
#>  6 <split [36/24]> Resample06
#>  7 <split [36/24]> Resample07
#>  8 <split [36/24]> Resample08
#>  9 <split [36/24]> Resample09
#> 10 <split [36/24]> Resample10
#> # … with 15 more rows

Created on 2021-03-09 by the reprex package (v1.0.0)

@juliasilge juliasilge requested a review from topepo March 10, 2021 18:48
@juliasilge
Copy link
Member Author

I know you have ambivalence about this @topepo but take a look and let's think about what we want to say in the warning.

Right now the warning gets triggered if pool is less than 0.1 and any of the groups turns out to be less than 10% of the sample.

@juliasilge juliasilge merged commit 9307a8a into master Mar 18, 2021
@juliasilge juliasilge deleted the expose-pool branch March 18, 2021 20:25
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

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 Apr 2, 2021
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.

more flexibility with stratification / grouped sampling
2 participants