Questions tagged [cross-validation]

Repeatedly withholding subsets of the data during model fitting in order to quantify the model performance on the withheld data subsets.

Refers to general procedures that attempt to determine the generalizability of a statistical result. Cross-validation arises frequently in the context of assessing how a particular model fit predicts future observations and how to optimally select model parameters.

Methods for cross-validation usually involve withholding a random subset of the data during model fitting (training set) and quantifying how accurate the withheld data are predicted (testing set) and repeating this process to get a measure of prediction accuracy. When this partitioning procedure happens once, it's called the holdout method.

The holdout method has two basic drawbacks:

  1. In problems where we have a sparse dataset we may not be able to afford setting aside a portion of the dataset for testing
  2. Since it is a single train-and-test experiment, the holdout estimate of error rate may have high variance due to the random nature in which the data was split.

One approach to dealing with these limitations is to use k-fold cross validation.

  1. Create k equally sized partitions (i.e. folds) of the data. In practice k is often set to 10.
  2. For each of the k partitions, use k-1 folds for training the model and the kth fold for testing.
  3. For each of the k experiments, you'll get a prediction error. The average of the k prediction errors is the true error rate.

The advantage of k-fold cross validation is that all the examples in the dataset are eventually used for both training and testing, so it matters less how the data is partitioned. The variance of the resulting estimate is reduced as k is increased. The disadvantage of this method is that the training algorithm has to be rerun from scratch k times, which means it takes k times as much computation to make an evaluation.

When we set k = n, this is known as leave-one out cross validation, because each partition is made up of n-1 training data and 1 testing.

3473 questions
45
votes
4 answers

Compendium of cross-validation techniques

I'm wondering if anybody knows of a compendium of cross-validation techniques with a discussion of the differences between them and a guide on when to use each of them. Wikipedia has a list of the most common techniques, but I'm curious if there are…
30
votes
1 answer

How does leave-one-out cross-validation work? How to select the final model out of $n$ different models?

I have some data and I want to build a model (say a linear regression model) out of this data. In a next step, I want to apply Leave-One-Out Cross-Validation (LOOCV) on the model so see how good it performs. If I understood LOOCV right, I build a…
theomega
  • 607
28
votes
1 answer

The cross validation (CV) and the generalized cross validation (GCV) statistics

I have found possibly conflicting definitions for the cross validation (CV) statistic and for the generalized cross validation (GCV) statistic associated with a linear model $Y = X\boldsymbol\beta + \boldsymbol\varepsilon$ (with a normal,…
Evan Aad
  • 1,433
25
votes
5 answers

Cross validation and parameter tuning

Can anyone tell me what exactly a cross-validation analysis gives as result? Is it just the average accuracy or does it give any model with parameters tuned? Because, I heard somewhere that cross-validation is used for parameter tuning.
24
votes
2 answers

How many times should we repeat a K-fold CV?

I came across this thread looking at the differences between bootstrapping and cross validation - great answer and references by the way. What I am wondering now is, if I was to perform repeated 10-fold CV say to calculate a classifier's accuracy,…
Neodyme
  • 895
22
votes
2 answers

Reporting variance of the repeated k-fold cross-validation

I have been using repeated k-fold cross validation and been reporting the mean (of the evaluation metric e.g., sensitivity, specificity) computed as the grand mean across the folds of different runs of the cross validation. However, I am not sure…
Ali S.
  • 321
18
votes
2 answers

How to evaluate the final model after k-fold cross-validation

As this question and its answer pointed out, k-fold cross validation (CV) is used for model selection, e.g. choosing between linear regression and neural network. It's also suggested that after deciding on which kind of model to use, the final…
qweruiop
  • 341
18
votes
1 answer

Cross validation with test data set

I am a bit confused about the application of cross-validation. So, if I have a big data set, I will split my data into test and training data and and perform validation on the test data. But if I have a small data set I would like to used…
Anni
  • 499
17
votes
1 answer

With k-fold cross-validation, do you average all $k$ models to build the final model?

When performing k-fold cross validation, I understand that you obtain the accuracy metrics by pointing all the folds except one at that one fold and make predictions, and then repeat this process $k$ times. You can then run accuracy metrics on all…
17
votes
1 answer

Should repeated cross-validation be used to assess predictive models?

I came across this 2012 article by Gitte Vanwinckelen and Hendrik Blockeel calling into question the utility of repeated cross-validation, which has become a popular technique for reducing the variance of cross-validation. The authors demonstrated…
RobertF
  • 6,084
14
votes
6 answers

How to split a data set to do 10-fold cross validation

Now I have a R data frame (training), can anyone tell me how to randomly split this data set to do 10-fold cross validation?
user22062
  • 1,419
  • 3
  • 17
  • 22
14
votes
3 answers

Perform cross-validation on train set or entire data set

I am a bit confused concerning how I should perform cross-validation to evaluate a statistical learning model. If I have a data set of 500 observations, should i divide it in a train and test set with for example 375 (75%) train observations and 125…
Kaangy
  • 187
  • 1
  • 5
13
votes
2 answers

Nested cross validation vs repeated k-fold

I know there are many topics(1,2,3), papers(1,2,3) and websites(1) that discuss this topic at length. However for the past two days I am reading all I can find about the subject and seems I hit a brick wall in terms of progress. As so, another view…
13
votes
2 answers

Repeated k-fold cross-validation vs. repeated holdout cross-validation: which approach is more reasonable?

I want to split my data 100 times (1/5 as testing, 4/5 as training), and the use the training data to build a model and the testing data to calculate the MSE. There are two ways we can do this: Do 5-fold cross validation 20 times, i.e., each time…
Lii
  • 1,096
11
votes
2 answers

In k-fold cross validation does the training subsample include test set?

In this Wikipedia page in subsection for K-fold cross validation it says "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…
ozi
  • 233
1
2 3
12 13