Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

makefolds

Generate random folds for cross-validation


Description

Random folds for use in a cross validation are generated. There is the option for stratified splitting as well.

Usage

makefolds(ina, nfolds = 10, stratified = TRUE, seed = FALSE)

Arguments

ina

A variable indicating the groupings.

nfolds

The number of folds to produce.

stratified

A boolean variable specifying whether stratified random (TRUE) or simple random (FALSE) sampling is to be used when producing the folds.

seed

A boolean variable. If set to TRUE, the folds will always be the same.

Details

I was inspired by the command in the package TunePareto in order to do the stratified version.

Value

A list with nfolds elements where each elements is a fold containing the indices of the data.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr

See Also

Examples

a <- makefolds(iris[, 5], nfolds = 5, stratified = TRUE)
table(iris[a[[1]], 5])  ## 10 values from each group

Directional

A Collection of R Functions for Directional Data Analysis

v4.9
GPL-2
Authors
Michail Tsagris, Giorgos Athineou, Anamul Sajib, Eli Amson, Micah J. Waldstein
Initial release
2021-03-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.