| calculate_resample_weights | R Documentation |
This convenience function calculates weights proportional to the number of observations in each resample's analysis set. Larger resamples get higher weights. This ensures that resamples with more data have proportionally more influence on the final aggregated metrics.
calculate_resample_weights(rset)
rset |
An rset object from rsample. |
This is particularly useful for time-based resamples (e.g., expanding window CV) or stratified sampling where resamples might have slightly different sizes, in which resamples are imbalanced.
A numeric vector of weights proportional to resample sizes, normalized to sum to 1.
add_resample_weights(), extract_resample_weights()
library(rsample)
folds <- vfold_cv(mtcars, v = 3)
weights <- calculate_resample_weights(folds)
weighted_folds <- add_resample_weights(folds, weights)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.