assign_fold | R Documentation |
If y has only two unique values, fold assignments are chosen so that the balance between outcomes is the same in each fold. This is useful for logistic regression and time-to-event data (to balance the fraction of observations that are censored).
assign_fold(y, folds, seed)
y |
Either (i) the vector of outcomes or (ii) a vector such as |
folds |
Number of folds |
seed |
(optional) set a seed for reproducibility |
A vector of integers indicating fold assignments
[cv.ncvreg()]
assign_fold(rnorm(11), 2)
assign_fold(1:41, 7)
assign_fold(1:41, 7) |> table()
data(Heart)
assign_fold(Heart$y, 7) |> head()
assign_fold(Heart$y, 7) |> table(Heart$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.