Skip to content

Instantly share code, notes, and snippets.

@limzunyuan
Created January 2, 2016 18:03
Show Gist options
  • Save limzunyuan/bffe7e630a364ac833d8 to your computer and use it in GitHub Desktop.
Save limzunyuan/bffe7e630a364ac833d8 to your computer and use it in GitHub Desktop.
% Returns indices for training set and test set
% e.g. partition(1) => [1:900 , 901:1004]
function [training_idx testing_idx] = partition(ith_partition, x2)
nrows = size(x2, 2);
test_set_start_index = floor((ith_partition - 1) / 10 * nrows) + 1;
test_set_end_index = floor(ith_partition / 10 * nrows);
testing_idx = test_set_start_index:test_set_end_index;
training_idx = setdiff(1:nrows, testing_idx);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment