Skip to content

Instantly share code, notes, and snippets.

@AlexEngelhardt
Created April 15, 2015 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexEngelhardt/73578fffad54b2398bcc to your computer and use it in GitHub Desktop.
Save AlexEngelhardt/73578fffad54b2398bcc to your computer and use it in GitHub Desktop.
Function to generate list of test set indices for cross validation
cv.folds <- function(n, folds = 10) { split(sample(1:n), rep(1:folds, length = n)) }
## cv_indices <- cv.folds(length(testable_rows), K) # list of 10 indices of testable_rows
## cv_groups <- lapply(cv_indices, function(x) testable_rows[x])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment