splitdata
Splits the dataset into training and test set based on the given ratio.
Syntax
[XTrain, XTest] = splitdata(X)
[XTrain, XTest] = splitdata(X,options)
[XTrain, XTest, yTrain, yTest] = splitdata(...)
Inputs
- X
- Input features of the dataset.
- options
- Type: struct
Outputs
- XTrain
- Input features of training set.
- XTest
- Input features of test set.
- yTrain
- Output features of training set.
- yTest
- Output features of test set.
Example
Usage of splitdata
X = rand(2500, 32);
y = rand(2500, 1);
options = struct;
options.y = y;
options.test_ratio = 0.3;
[XTrain, XTest, yTrain, yTest] = splitdata(X, options);
> size(X)
ans = [Matrix] 1 x 2
2500 32
> size(XTrain)
ans = [Matrix] 1 x 2
1750 32
> size(XTest)
ans = [Matrix] 1 x 2
750 32
>