Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/KPMtools/rnd_partition.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function [train, test] = rnd_partition(data, train_percent); |
wolffd@0 | 2 % function [train, test] = rnd_partition(data, train_percent); |
wolffd@0 | 3 % |
wolffd@0 | 4 % data(:,i) is the i'th example |
wolffd@0 | 5 % train_percent of these columns get put into train, the rest into test |
wolffd@0 | 6 |
wolffd@0 | 7 N = size(data, 2); |
wolffd@0 | 8 ndx = randperm(N); |
wolffd@0 | 9 k = ceil(N*train_percent); |
wolffd@0 | 10 train_ndx = ndx(1:k); |
wolffd@0 | 11 test_ndx = ndx(k+1:end); |
wolffd@0 | 12 train = data(:, train_ndx); |
wolffd@0 | 13 test = data(:, test_ndx); |