Skip to content

Commit

Permalink
Included H holdout
Browse files Browse the repository at this point in the history
  • Loading branch information
pagutierrez committed Jan 20, 2018
1 parent 933a010 commit a10f398
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/code-examples/exampleERAHHoldout.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
% Load data
ERAData = table2array(readtable('../../exampledata/ERA.csv'));

% Check the first 20 rows
ERAData(1:20,:)

% Extract targets
targets = ERAData(:,end);

% Generate h holdout partitions
h=30;

% Prepare filesystem
nameDataset = 'era';
rootDir = fullfile('..', '..', 'exampledata', '30-holdout', nameDataset);
mkdir(rootDir);
rootDir = fullfile(rootDir,'matlab');
mkdir(rootDir);

% For each partitions
for ff = 1:h
CVO = cvpartition(targets,'HoldOut',0.25); % 25% of patterns for the test set
trIdx = CVO.training(1);
teIdx = CVO.test(1);
dlmwrite(fullfile(rootDir,sprintf('train-%s.%d',nameDataset,ff-1)),ERAData(trIdx,:),' ');
dlmwrite(fullfile(rootDir,sprintf('test-%s.%d',nameDataset,ff-1)),ERAData(teIdx,:),' ');
end

0 comments on commit a10f398

Please sign in to comment.