partition data for cross-凯发k8网页登录
partition data for cross-validation
description
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.
creation
syntax
description
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.
input arguments
properties
object functions
repartition data for cross-validation | |
test indices for cross-validation | |
training indices for cross-validation |
examples
tips
if you specify
group
as the first input argument tocvpartition
, then the function discards rows of observations corresponding to missing values ingroup
.if you specify
group
as the first input argument tocvpartition
, 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 tocvpartition
isgroup
.
extended capabilities
version history
introduced in r2008a
see also
| | |