// use built-in function samplesize = size( matrix , 1); c = cvpartition(samplesize, 'kfold' , k); % return the indexes on each fold ///// output in matlab console K-fold cross validation partition N: 10 NumTestSets: 4 TrainSize: 8 7 7 8 TestSize: 2 3 3 2 ////////////////////// for i=1 : k trainIdxs = find(training(c,i) ); %training(c,i); // 1 means in train , 0 means in test testInxs = find(test(c,i) ); % test(c,i); // 1 means in test , 0 means in train trainMatrix = matrix ( matrix(trainIdxs ), : ); testMatrix = matrix ( matrix(testIdxs ), : ); end //// now calculate performance %% calculate performance of a partiti...
Comments
Post a Comment