Documentation Center

  • Trial Software
  • Product Updates

repartition

Class: cvpartition

Repartition data for cross-validation

Syntax

cnew = repartition(c)

Description

cnew = repartition(c) constructs an object cnew of the cvpartition class defining a random partition of the same type as c, where c is also an object of the cvpartition class.

Repartitioning is useful for Monte-Carlo repetitions of cross-validation analyses. repartition is called by crossval when the 'mcreps' parameter is specified.

Examples

Partition and repartition 100 observations for 3-fold cross-validation:

c = cvpartition(100,'kfold',3)
c = 
K-fold cross validation partition
             N: 100
   NumTestSets: 3
     TrainSize: 67  66  67
      TestSize: 33  34  33

cnew = repartition(c)
cnew = 
K-fold cross validation partition
             N: 100
   NumTestSets: 3
     TrainSize: 67  66  67
      TestSize: 33  34  33

Check for equality of the test data in the first fold:

isequal(test(c,1),test(cnew,1))
ans =
     0

See Also

Was this topic helpful?