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

Add a leave-group-out resampling method #23

Closed
topepo opened this issue Sep 21, 2017 · 2 comments
Closed

Add a leave-group-out resampling method #23

topepo opened this issue Sep 21, 2017 · 2 comments

Comments

@topepo
Copy link
Member

topepo commented Sep 21, 2017

Similar to caret's groupKFold.

@topepo
Copy link
Member Author

topepo commented Oct 6, 2017

There are a bunch of tests that now pass (tibbles!).

Please test and/or evaluate to give feedback.

Here example is:

> set.seed(3527)
> test_data <- data.frame(id = sort(sample(1:20, size = 80, replace = TRUE)))
> test_data$dat <- runif(nrow(test_data))
> 
> set.seed(5144)
> split_by_id <- group_vfold_cv(test_data, group = "id")
> 
> get_id_left_out <- function(x)
+   unique(assessment(x)$id)
> 
> library(purrr)
> table(map_int(split_by_id$splits, get_id_left_out))

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 
 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
> 
> set.seed(5144)
> split_by_some_id <- group_vfold_cv(test_data, group = "id", v = 7)
> held_out <- map(split_by_some_id$splits, get_id_left_out)
> table(unlist(held_out))

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 
 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
> # number held out per resample:
> map_int(held_out, length)
1 2 3 4 5 6 7 
3 3 3 3 3 3 2 

@topepo topepo closed this as completed Oct 6, 2017
@github-actions
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 Feb 22, 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

No branches or pull requests

1 participant