View source: R/stratified_foldid.R
| stratified_foldid | R Documentation |
Assigns each observation to one of nfolds folds so that both classes
are spread as evenly as possible across folds. This prevents a small
class from being concentrated in a single fold, which would leave a
cross-validation training split with fewer than the two observations
per class that glmnet::glmnet() requires for binomial fits.
stratified_foldid(y, nfolds)
y |
Binary (0/1) vector of class labels. |
nfolds |
Number of folds. |
Integer vector of fold assignments in 1:nfolds, the same
length as y, suitable for the foldid argument of
glmnet::cv.glmnet().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.