trainTestSplit

Purpose

Returns test and training splits for a given set of dependent and independent variables.

Format

{ y_train, y_test, x_train, x_test } = trainTestSplit(y, X, train_pct);
{ y_train, y_test, x_train, x_test } = trainTestSplit(dataset, formula, train_pct);

Input

y
Nx1 vector, or NxK matrix of dependent variables.
X
NxP matrix of independent variables.
dataset
String, the name of a dataset.
formula
String, a GAUSS formula string specifying the dependent and independent variables.
train_pct
Scalar, between 0 and 1 specifying the percentage of observations for the training set.

Output

y_train
The (train_pct * N) observations from the original y which correspond to the observations selected for X_train.
y_test
The remaining observations from the original y not selected for the training set.
X_train
(train_pct * N)xP matrix of independent variables.
X_test
The remaining observations from the original X which were not selected to be in the training set.

Remarks

The observations from X and y are first randomly shuffled such that the corresponding rows of X and y are kept together. For repeatable shuffling, use the rndseed keyword before calling trainTestSplit.

See also

cvSplit, rndi, sampleData

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

REQUEST A FREE QUOTE

Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap