Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Split train/test with rsample
set.seed(100)
initSplit <- initial_split(X, prop = .9,
strata = "Y")
trainSet <- training(initSplit)
testSet <- testing(initSplit)
# Create 5-fold cross-validation, convert to caret class
set.seed(100)
myFolds <- vfold_cv(trainSet, v = 5, repeats = 5,
strata = "Y") %>%
rsample2caret()
ctrl <- trainControl(method = "cv",
selectionFunction = "oneSE")
ctrl$index <- myFolds$index
ctrl$indexOut <- myFolds$indexOut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment