getfold

Utility function used to retrieve folds in iterations which are returned by splitter functions.

Attention: Available only with Twin Activate commercial edition.

Syntax

[train_idxs, valid_idxs] = getfold(folds,fold_count)

Inputs

folds
Array returned by splitter functions such as KFold.
Type: double
Dimension: cell
fold_count
Current fold to be returned during iterations.
Type: integer
Dimension: scalar

Outputs

train_idxs
Training set indices for current fold.
Type: integer
Dimension: vector
valid_idxs
Validation set indices for current fold.
Type: integer
Dimension: vector

Example

Usage of getfold

X = [1 2; 3 4; 1 2; 3 4];
options.num_folds = 3; 
options.seed = 234;
options.shuffle = true;
folds = kfold(X, options); 
for fold_count=1:folds.num_folds
	[train_idxs, valid_idxs] = getfold(folds, fold_count);
	printf('\nTRAIN: '); printf('%d ', train_idxs);
	printf('\nVALID: '); printf('%d ', valid_idxs);
	printf('\n=============');
end
TRAIN: 1 4 
VALID: 3 2 
=============
TRAIN: 2 3 4 
VALID: 1 
=============
TRAIN: 1 2 3 
VALID: 4 
=============