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 "constructors" for rsample & rset objects #40

Closed
ClaytonJY opened this issue Jul 3, 2018 · 2 comments · Fixed by #139
Closed

Expose "constructors" for rsample & rset objects #40

ClaytonJY opened this issue Jul 3, 2018 · 2 comments · Fixed by #139

Comments

@ClaytonJY
Copy link
Contributor

Lately I've been making splits and rsets in some non-standard ways for internal (work) packages. I've been getting along fine using new_rset/make_splits/rsplit, but there's always a little discomfort in depending on triple-colon hidden functions in another package.

Maybe this is already on the roadmap, but I would greatly appreciate exported functions for making custom objects from this package. I suspect you'll want to wait until you've solidified the API some more, but hopefully by making a note of it here you might consider @export-ing new_rset/make_splits when the time is right. Thanks!

@dougmet
Copy link

dougmet commented Jul 3, 2019

I've been using caret2rsample to achieve this without triple colons. Seeing as caret::trainControl just returns a list, so long as you have the right bits it seems to work.

I make a list called indices, which has two named lists: in_indices is a list which corresponds to index in trainControl. out_indices corresponds to indexOut. The names are the names of each resample.

indices_to_rsample <- function(indices, data, method = "cv", repeats = NA,
                               number = 10) {

  # in_indices and out_indices must be named with the same names
  ctrl <- list(index = indices$in_indices,
               indexOut = indices$out_indices,
               method = method,
               repeats = repeats,
               number = number)

  rsample::caret2rsample(ctrl, data)

}

Now this relies on the caret2rsample interface remaining constant so I'm hoping for a better way soon but it at least stops CMD check from crying.

@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 21, 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 a pull request may close this issue.

2 participants