
The rsample package provides functions to create different types ofresamples and corresponding classes for their analysis. The goal is tohave a modular set of methods that can be used for:
The scope of rsample is to provide the basic building blocks forcreating and analyzing resamples of a data set, but this package doesnot include code for modeling or calculating statistics. TheWorkingwith Resample Sets vignette gives a demonstration of how rsampletools can be used when building models.
Note that resampled data sets created by rsample are directlyaccessible in a resampling object but do not contain much overhead inmemory. Since the original data is not modified, R does not make anautomatic copy.
For example, creating 50 bootstraps of a data set does not create anobject that is 50-fold larger in memory:
library(rsample)library(mlbench)data(LetterRecognition)lobstr::obj_size(LetterRecognition)#> 2,644,640 Bset.seed(35222)boots<-bootstraps(LetterRecognition,times =50)lobstr::obj_size(boots)#> 6,686,776 B# Object size per resamplelobstr::obj_size(boots)/nrow(boots)#> 133,735.5 B# Fold increase is <<< 50as.numeric(lobstr::obj_size(boots)/lobstr::obj_size(LetterRecognition))#> [1] 2.528426Created on 2022-02-28 by thereprex package(v2.0.1)
The memory usage for 50 bootstrap samples is less than 3-fold morethan the original data set.
To install it, use:
install.packages("rsample")And the development version fromGitHub with:
# install.packages("pak")pak::pak("rsample")This project is released with aContributorCode of Conduct. By contributing to this project, you agree to abideby its terms.
For questions and discussions about tidymodels packages,modeling, and machine learning, pleaseposton Posit Community.
If you think you have encountered a bug, pleasesubmit anissue.
Either way, learn how to create and share areprex(a minimal, reproducible example), to clearly communicate about yourcode.
Check out further details oncontributing guidelinesfor tidymodels packages andhow to get help.