test

Class: cvpartition

Test indices for cross-validation

Syntax

idx = test(c)
idx = test(c,i)

Description

idx = test(c) returns the logical vector idx of test indices for an object c of the cvpartition class of type 'holdout' or 'resubstitution'.

If c.Type is 'holdout', idx specifies the observations in the test set.

If c.Type is 'resubstitution', idx specifies all observations.

idx = test(c,i) returns the logical vector idx of test indices for repetition i of an object c of the cvpartition class of type 'kfold' or 'leaveout'.

If c.Type is 'kfold', idx specifies the observations in the test set in fold i.

If c.Type is 'leaveout', idx specifies the observation left out at repetition i.

Examples

Identify the test indices in the first fold of a partition of 10 observations for 3-fold cross-validation:

c = cvpartition(10,'kfold',3)
c = 
K-fold cross validation partition
             N: 10
   NumTestSets: 3
     TrainSize: 7  6  7
      TestSize: 3  4  3

test(c,1)
ans =
     1
     1
     0
     0
     0
     0
     0
     0
     1
     0
Was this topic helpful?