-1

Please tell me how to extract the remaining 50 data samples from the 'Data' dataset for testing the trained NN. Is there any other way to separate the training and testing data for classification purpose. Please help me.. Thank you

RACHITA PATRO
  • 103
  • 1
  • 1
  • 11

1 Answers1

1

Instead of using datasample, use randperm to generate a random permutation of values from 1 up to 150, then select the first 100 indices to be part of your training data set, and the last 50 indices to be part of the testing data set. Supposing Data was a M x N matrix where M was the total number of samples and N is the dimensionality of one sample, you would do this:

ind = randperm(150);
Ytrain = Data(ind(1:100), :);
Ytest = Data(ind(101:150), :);

However, if your situation is reverse where each column represents a sample and not each row, you simply do:

ind = randperm(150);
Ytrain = Data(:, ind(1:100));
Ytest = Data(:, ind(101:150));
rayryeng
  • 102,964
  • 22
  • 184
  • 193