RSNNS (version 0.4-12)

splitForTrainingAndTest: Function to split data into training and test set

Description

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.

Usage

splitForTrainingAndTest(x, y, ratio = 0.15)

Arguments

x

inputs

y

targets

ratio

ratio of training and test sets (default: 15% of the data is used for testing)

Value

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

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataCamp Workspace