folds: Cross Validation Folds

Description Usage Arguments Details Examples

Description

Map an object x into equal (or nearly equal) size folds. If x is a positive integer, a vector of FoldIDs of length matching x is returned, otherwise If x is a vector, a matching vector of FoldIDs is returned. If x is a data.table, a list of partitions of x is returned.

Usage

1
folds(x, nfolds = 5L, stratified = FALSE, seed = NULL)

Arguments

x

A positive integer, a vector of values or a data.table object

nfolds

How many folds?

stratified

If x is a vector then TRUE or FALSE indicating whether x's split the class's of x proportionally. If x is a data.table then stratified should be FALSE or the name of a column in x on which to perform stratification. Note that stratification is implemented for categorical, logical, AND numeric x

seed

Random number seed

Details

Convenient method for mapping an object into equal size folds, potentially with stratification

Examples

1
2
3
4
5
6
library(data.table)
folds(8, nfolds=2)
folds(alien.train$IsAlien, nfolds=2)
folds(alien.train$IsAlien, nfolds=2, stratified=TRUE, seed=2016)
folds(alien.train$IQScore, nfolds=2, stratified=TRUE, seed=2016)
folds(alien.train, nfolds=2, stratified="IsAlien", seed=2016)

mltools documentation built on May 2, 2019, 5:22 a.m.