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

inner_split(): S3 method to retrive splitting arguments #491

Closed
topepo opened this issue May 23, 2024 · 3 comments
Closed

inner_split(): S3 method to retrive splitting arguments #491

topepo opened this issue May 23, 2024 · 3 comments

Comments

@topepo
Copy link
Member

topepo commented May 23, 2024

It's a bit tedious to do this:

library(tidymodels)

set.seed(19)
ad_v_fold <- vfold_cv(ad_data, v = 5, strata = Class)
ad_v_fold_attr <- attributes(ad_v_fold)[ c("v", "repeats", "strata", "breaks", "pool")]

v_fold_inner <- inner_split(ad_v_fold$splits[[1]], ad_v_fold_attr)

Created on 2024-05-23 with reprex v2.0.2

IIRC you have an internal function to do this?

@simonpcouch
Copy link
Contributor

rsample/R/misc.R

Lines 298 to 312 in 7d35a8e

#' Get the split arguments from an rset
#' @param rset An `rset` object.
#' @return A list of arguments used to create the rset.
#' @keywords internal
#' @export
.get_split_args <- function(rset) {
all_attributes <- attributes(rset)
args <- names(formals(all_attributes$class[[1]]))
split_args <- all_attributes[args]
split_args <- split_args[!is.na(names(split_args))]
if (identical(split_args$strata, FALSE)) {
split_args$strata <- NULL
}
split_args
}

@hfrick
Copy link
Member

hfrick commented May 24, 2024

Closing this as the helper exist :)

@topepo it's currently exported but that might change. If you find usage for it that suggests it should stay exported please comment on #495 🙌

@hfrick hfrick closed this as completed May 24, 2024
Copy link

github-actions bot commented Jun 8, 2024

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 Jun 8, 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

No branches or pull requests

3 participants