Comparison Between Performance of Classifiers
Comparison Between Performance of Classifiers
3. Introduction to Cross-Validation
However, the train-split method has certain limitations. When
the dataset is small, the method is prone to high
variance. Due to the random partition, the results can be entirely
different for different test sets. Why? Because in some
partitions, samples that are easy to classify get into the test set,
while in others, the test set receives the ‘difficult’ ones.
To deal with this issue, we use cross-validation to
evaluate the performance of a machine learning model. In
cross-validation, we don’t divide the dataset into training and test
sets only once. Instead, we repeatedly partition the dataset into
smaller groups and then average the performance in each group.
That way, we reduce the impact of partition randomness on the
results.
Many cross-validation techniques define different ways to divide
the dataset at hand. We’ll focus on the two most frequently used:
the k-fold and the leave-one-out methods.
4. K-Fold Cross-Validation
In k-fold cross-validation, we first divide our dataset into k equally
sized subsets. Then, we repeat the train-test method k
times such that each time one of the k subsets is used as
a test set and the rest k-1 subsets are used together as a
training set. Finally, we compute the estimate of the model’s
performance estimate by averaging the scores over the k trials.
For example, let’s suppose that we have a dataset S =
{x1,x2,x3,x4,x5,x6} containing 6 samples and that we want to
perform a 3-fold cross-validation.
First, we divide S into 3 subsets randomly. For instance:
S1= {x1,x2}
S2={x3,x4}
S3={x5,x6}
5 Leave-One-Out Cross-Validation
S1={x1}
S2={x2}
S3={x3}
S4={x4}
S5={x5}
S6={x6}
Iterating over them, we use S/ Si as the training data in
iteration i=1,2,…6,, and evaluate the model on Si :
6. Comparison
An important factor when choosing between the k-fold and
the LOO cross-validation methods is the size of the
dataset.
When the size is small, LOO is more appropriate since it will
use more training samples in each iteration. That will enable our
model to learn better representations.
Conversely, we use k-fold cross-validation to train a model
on a large dataset since LOO trains models, one per sample in
the data. When our dataset contains a lot of samples, training so
many models will take too long. So, the k-fold cross-validation is
more appropriate.
Also, in a large dataset, it is sufficient to use less than folds
since the test folds are large enough for the estimates to be
sufficiently precise.