---
title: "What is the purpose of cross-validation in machine learning? How is it performed?"  
description: "What is the purpose of cross-validation in machine learning? How is it performed?"  
author: "Revati S Misra"  
published: 2023-05-28  
updated: 2023-05-29  
canonical: https://www.mindstick.com/forum/158513/what-is-the-purpose-of-cross-validation-in-machine-learning-how-is-it-performed  
category: "big data"  
tags: ["bigdata", "machine learning", "data science"]  
reading_time: 3 minutes  

---

# What is the purpose of cross-validation in machine learning? How is it performed?

What is the [purpose](https://yourviews.mindstick.com/view/247/no-fail-policy-failing-its-purpose) of [cross](https://www.mindstick.com/forum/33892/how-to-handle-cross-thread-exception-in-winforms)-[validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) in [machine learning](https://www.mindstick.com/articles/13070/rising-popularity-of-machine-learning-classes-in-bangalore)? How is it performed?

## Replies

### Reply by Aryan Kumar

Cross-validation is a technique used in machine [learning](https://www.mindstick.com/articles/126221/instructional-design-for-elearning-why-it-is-so-important) to evaluate the performance of a model on unseen data. It is done by splitting the data into two sets: a training set and a test set. The model is trained on the training set and then evaluated on the test set. This process is repeated multiple times, with different data points used for the training and test sets each time. The average performance of the model on the test sets is then used to assess its overall performance.

There are many different ways to perform cross-validation. One common method is called k-fold cross-validation. In k-fold cross-validation, the data is split into k folds. The model is trained on k-1 folds and then evaluated on the remaining fold. This process is repeated k times, with a different fold used for evaluation each time. The average performance of the model on the test folds is then used to assess its overall performance.

Cross-validation is a valuable tool for evaluating the performance of machine learning models. It can help to ensure that the model is not overfitting the training data and that it is able to generalize to unseen data. Cross-validation can also be used to compare the performance of different models.

Here are some of the advantages of cross-validation:

- It can help to avoid overfitting, which is a problem that occurs when a model is too closely fit to the training data and does not generalize well to new data.
- It can be used to compare the performance of different models.
- It can be used to select the best hyperparameters for a model.

Here are some of the disadvantages of cross-validation:

- It can be computationally expensive, especially if the data set is large.
- It can be time-consuming, especially if the model takes a long time to train.
- It can be difficult to interpret the results of cross-validation, especially if there are multiple models being compared.

Overall, cross-validation is a valuable tool for evaluating the performance of machine learning models. It can help to ensure that the model is not overfitting the training data and that it is able to generalize to unseen data. Cross-validation can also be used to compare the performance of different models.


---

Original Source: https://www.mindstick.com/forum/158513/what-is-the-purpose-of-cross-validation-in-machine-learning-how-is-it-performed

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
