2

I'm using tidymodels framework for creating stratified resample folds for cross-validation in a random forest model. Is it possible to actually access and view / plot the data within each of these folds? Reproducible code below:

library(tidyverse)
library(tidymodels)

df_cv <- vfold_cv(iris, v = 10, strata =Species)
jaykay
  • 71
  • 7

1 Answers1

2

The output of vfold_cv is an rsplit object. You can run split1 <- get_rsplit(df_cv, index = 1) to get the split. analysis(split1) will give you the analysis data frame and assessment(split1) will get you the assessment data frame.

You can also run tidy(split1) to get information about which rows went to the analysis set vs. which rows went to the assessment set.

This reference gives a little bit more information about what you do with an rsplit object.

For a more in-depth understanding of the rsplit class, you can check out the code here.

mfg3z0
  • 561
  • 16