Cross-validation and model evaluation techniques
Cross-Validation is a statistical method of evaluating and comparing learning algorithms by dividing data into two segments: one used to learn or train a model and the other used to validate the model. In typical cross-validation, the training and validation sets must cross-over in successive rounds such that each data point has a chance of being validated against. The basic form of cross-validation is k-fold cross-validation. Other forms of cross-validation are special cases of k-fold cross-validation or involve repeated rounds of k-fold cross-validation.
Types of Cross-Validation
There are several types of cross validation techniques, including k-fold cross validation, leave-one-out cross validation, and Holdout validation, Stratified Cross-Validation. The choice of technique depends on the size and nature of the data, as well as the specific requirements of the modeling problem.
1. Holdout Validation
In Holdout Validation, we perform training on the 50% of the given dataset and rest 50% is used for the testing purpose. It’s a simple and quick way to evaluate a model. The major drawback of this method is that we perform training on the 50% of the dataset, it may possible that the remaining 50% of the data contains some important information which we are leaving while training our model i.e. higher bias.
2. LOOCV (Leave One Out Cross Validation)
In this method, we perform training on the whole dataset but leaves only one data-point of the available dataset and then iterates for each data-point. In LOOCV, the model is trained on n−1
n−1 samples and tested on the one omitted sample, repeating this process for each data point in the dataset. It has some advantages as well as disadvantages also.
An advantage of using this method is that we make use of all data points and hence it is low bias.
The major drawback of this method is that it leads to higher variation in the testing model as we are testing against one data point. If the data point is an outlier it can lead to higher variation. Another drawback is it takes a lot of execution time as it iterates over ‘the number of data points’ times.
3. Stratified Cross-Validation
It is a technique used in machine learning to ensure that each fold of the cross-validation process maintains the same class distribution as the entire dataset. This is particularly important when dealing with imbalanced datasets, where certain classes may be underrepresented. In this method,
The dataset is divided into k folds while maintaining the proportion of classes in each fold.
During each iteration, one-fold is used for testing, and the remaining folds are used for training.
Recommended by LinkedIn
The process is repeated k times, with each fold serving as the test set exactly once.
Stratified Cross-Validation is essential when dealing with classification problems where maintaining the balance of class distribution is crucial for the model to generalize well to unseen data.
4. K-Fold Cross Validation
In K-Fold Cross Validation, we split the dataset into k number of subsets (known as folds) then we perform training on the all the subsets but leave one(k-1) subset for the evaluation of the trained model. In this method, we iterate k times with a different subset reserved for testing purpose each time.
Advantages and Disadvantages of Cross Validation
Advantages:
Disadvantages:
What is model evaluation?
Model evaluation (or model validation) is the process of assessing the performance of a trained ML model on a (holdout) dataset. You want to establish the model’s ability to generalize - to make good predictions on new, unseen data.
What are the most common model evaluation metrics?
For a binary classification problem, common evaluation metrics include accuracy, precision, recall, F1 score, and area under the receiver operating characteristic curve (ROC AUC). For multi-class classification problems, a confusion matrix is often used that shows the counts of TPs (true positives), FPs (false positives), TNs (true negatives), and FNs (false negatives) for all predictions made using the test set. For regression problems, metrics such as mean squared error (MSE) and R-squared are commonly used.