Learn R Programming

llama (version 0.6)

trainTest: Train / test split

Description

Split a data set into train and test set.

Usage

trainTest(data, trainpart = 0.6, stratify = T)

Arguments

data
the data to use. The structure returned by input.
trainpart
the fraction of the data to use for training. Default 0.6.
stratify
whether to stratify the folds. Defaults to TRUE.

Value

  • traina (one-element) list of data sets for training.
  • testa (one-element) list of data sets for testing.
  • ...the original members of data. See input.

Details

Partitions the data set into training and test set according to the specified fraction. The training and test set are added to the original data and returned. If requested, the distribution of the best algorithms in training and test set is approximately the same, i.e. the sets are stratified.

See Also

cvFolds

Examples

Run this code
data(satsolvers)
trainTest = trainTest(satsolvers)

# use 50-50 split instead of 60-40
trainTest1 = trainTest(satsolvers, 0.5)

# don't stratify
trainTestU = trainTest(satsolvers, stratify=FALSE)

Run the code above in your browser using DataLab