Partition data for cross-validation
cvpartition defines a random partition on a data set. Use this partition
to define training and test sets for validating a statistical model using cross-validation.
Use training to extract the training indices and
test to extract the test indices for cross-validation. Use
repartition to define a new random partition of the same type as a
given cvpartition object.
returns a c = cvpartition(n,'KFold',k)cvpartition object c that defines a
random nonstratified partition for k-fold cross-validation on
n observations. The partition randomly divides the observations
into k disjoint subsamples, or folds, each of which has
approximately the same number of observations.
creates a random partition for stratified c = cvpartition(group,'KFold',k)k-fold cross-validation.
Each subsample, or fold, has approximately the same number of observations and contains
approximately the same class proportions as in group.
When you specify group as the first input argument,
cvpartition discards rows of observations corresponding to
missing values in group.
returns a c = cvpartition(group,'KFold',k,'Stratify',stratifyOption)cvpartition object c that defines a
random partition for k-fold cross-validation. If you specify
'Stratify',false, then cvpartition ignores the
class information in group and creates a nonstratified random
partition. Otherwise, the function implements stratification by default.
returns an object c = cvpartition(group,'Holdout',p,'Stratify',stratifyOption)c that defines a random partition into a training
set and a test, or holdout, set. If you specify 'Stratify',false,
then cvpartition creates a nonstratified random partition.
Otherwise, the function implements stratification by default.
creates a random partition for leave-one-out cross-validation on c = cvpartition(n,'Leaveout')n
observations. Leave-one-out is a special case of 'KFold' in which the
number of folds equals the number of observations.
c = cvpartition(
creates an object n,'Resubstitution')c that does not partition the data. Both the
training set and the test set contain all of the original n
observations.
repartition | Repartition data for cross-validation |
test | Test indices for cross-validation |
training | Training indices for cross-validation |
If you specify group as the first input argument to
cvpartition, then the function discards rows of observations
corresponding to missing values in group.
If you specify group as the first input argument to
cvpartition, then the function implements stratification by
default. You can specify 'Stratify',false to create a nonstratified
random partition.
You can specify 'Stratify',true only when the first input argument
to cvpartition is group.