Function to split data into training and test set
Split the input and target values to a training and a test set. Test set is taken from the end of the data. If the data is to be shuffled, this should be done before calling this function.
splitForTrainingAndTest(x, y, ratio = 0.15)
x |
inputs |
y |
targets |
ratio |
ratio of training and test sets (default: 15% of the data is used for testing) |
a named list with the following elements:
inputsTrain |
a matrix containing the training inputs |
targetsTrain |
a matrix containing the training targets |
inputsTest |
a matrix containing the test inputs |
targetsTest |
a matrix containing the test targets |
data(iris) #shuffle the vector iris <- iris[sample(1:nrow(iris),length(1:nrow(iris))),1:ncol(iris)] irisValues <- iris[,1:4] irisTargets <- decodeClassLabels(iris[,5]) splitForTrainingAndTest(irisValues, irisTargets, ratio=0.15)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.