wolffd@0: % --- wolffd@0: % class cvpartition_trunctrain wolffd@0: % NOTE: this is a fake cvpartition double for wolffd@0: % using cvpartitions in truncated-training size experiments wolffd@0: % --- wolffd@0: classdef cvpartition_trunctrain wolffd@0: wolffd@0: properties (Hidden) wolffd@0: wolffd@0: mtest; wolffd@0: mtraining; wolffd@0: end wolffd@0: properties wolffd@0: N; wolffd@0: NumTestSets; wolffd@0: TrainSize; wolffd@0: TestSize; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: methods wolffd@0: wolffd@0: % --- wolffd@0: % constuctor: directly calculates the truncated testset wolffd@0: % --- wolffd@0: function P = cvpartition_trunctrain(Pin, perctrain) wolffd@0: wolffd@0: P.N = Pin.N; wolffd@0: P.NumTestSets = Pin.NumTestSets; wolffd@0: wolffd@0: for i = 1:Pin.NumTestSets wolffd@0: wolffd@0: % copy testing data wolffd@0: P.TestSize(i) = Pin.TestSize(i); wolffd@0: P.mtest{i} = Pin.test(i); wolffd@0: wolffd@0: % calculate new training size wolffd@0: P.TrainSize(i) = ceil(perctrain * Pin.TrainSize(i)); wolffd@0: wolffd@0: % get actual training indices wolffd@0: idx = find(Pin.training(i)); wolffd@0: wolffd@0: % --- wolffd@0: % TODO: save the permutation in a global variable, wolffd@0: % tomake the same smaller set available wolffd@0: % for all further experiments. wolffd@0: % moreover, it would be great if the smaller training sets wolffd@0: % are subsets of the bigger ones wolffd@0: % --- wolffd@0: tokeep = randperm(numel(idx)); wolffd@0: tokeep = tokeep(1:P.TrainSize(i)); wolffd@0: wolffd@0: % get indices to keep wolffd@0: idx = idx(tokeep); wolffd@0: wolffd@0: % build truncated training set wolffd@0: P.mtraining{i} = false(P.N, 1); wolffd@0: P.mtraining{i}(idx) = true; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: function out = test(P, i) wolffd@0: wolffd@0: out = P.mtest{i}; wolffd@0: end wolffd@0: wolffd@0: function out = training(P, i) wolffd@0: wolffd@0: out = P.mtraining{i}; wolffd@0: end wolffd@0: wolffd@0: end wolffd@0: end