*分成多分，留一份验证。*

*K*-fold cross-validation

In *k*-fold cross-validation, the original sample is randomly partitioned into *k* equal size subsamples. Of the *k* subsamples, a single subsample is retained as the validation data for testing the model, and the remaining *k* − 1 subsamples are used as training data. The cross-validation process is then repeated *k* times (the *folds*), with each of the *k* subsamples used exactly once as the validation data. The *k* results from the folds can then be averaged (or otherwise combined) to produce a single estimation. The advantage of this method over repeated random sub-sampling (see below) is that all observations are used for both training and validation, and each observation is used for validation exactly once. 10-fold cross-validation is commonly used,^{[6]} but in general *k* remains an unfixed parameter [1].

In *stratified* *k*-fold cross-validation, the folds are selected so that the mean response value is approximately equal in all the folds. In the case of a dichotomous classification, this means that each fold contains roughly the same proportions of the two types of class labels.

### 2-fold cross-validation

This is the simplest variation of *k*-fold cross-validation. Also, called holdout method.^{[7]} For each fold, we randomly assign data points to two sets *d*_{0} and *d*_{1}, so that both sets are equal size (this is usually implemented by shuffling the data array and then splitting it in two). We then train on *d*_{0} and test on *d*_{1}, followed by training on *d*_{1} and testing on *d*_{0}.

This has the advantage that our training and test sets are both large, and each data point is used for both training and validation on each fold.

### Repeated random sub-sampling validation

This method randomly splits the dataset into training and validation data. For each such split, the model is fit to the training data, and predictive accuracy is assessed using the validation data. The results are then averaged over the splits. The advantage of this method (over *k*-fold cross validation) is that the proportion of the training/validation split is not dependent on the number of iterations (folds). The disadvantage of this method is that some observations may never be selected in the validation subsample, whereas others may be selected more than once. In other words, validation subsets may overlap. This method also exhibits Monte Carlo variation, meaning that the results will vary if the analysis is repeated with different random splits.

In a stratified variant of this approach, the random samples are generated in such a way that the mean response value (i.e. the dependent variable in the regression) is equal in the training and testing sets. This is particularly useful if the responses are dichotomous with an unbalanced representation of the two response values in the data.

### Leave-one-out cross-validation

As the name suggests, leave-one-out cross-validation (**LOOCV**) involves using a single observation from the original sample as the validation data, and the remaining observations as the training data. This is repeated such that each observation in the sample is used once as the validation data. This is the same as a *K*-fold cross-validation with *K* being equal to the number of observations in the original sampling.