---
title: "Training, Validation & Test Data in Machine Learning"
description: "Training, Validation and Test Data in Machine Learning When building a Machine Learning model, we usually do not use the entire dataset for training. Instead, the available data is divided into different parts so that we can **train the model,…"
url: "https://csestudy247.com/docs/training-validation-test-data-in-machine-learning/"
updated: "2026-09-23"
category: ML
---

# Training, Validation & Test Data in Machine Learning

Training, Validation and Test Data in Machine Learning

When building a Machine Learning model, we usually do not use the entire dataset for training. Instead, the available data is divided into different parts so that we can **train the model, tune it, and evaluate it fairly**. The three important parts are:

- **Training Set**
- **Validation Set**
- **Test Set**

## Machine Learning Data Splitting

 graph TD A\["📊 Complete Dataset"\] A --> B\["🏋️ Training Set"\] A --> C\["⚙️ Validation Set"\] A --> D\["🧪 Test Set"\] B --> E\["🧠 Learn Model Parameters"\] C --> F\["🔧 Tune Model / Hyperparameters"\] D --> G\["📊 Final Evaluation"\] E --> H\["🤖 Final Model"\] F --> H H --> G style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style E fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style F fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style H fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:3px

---

## 1. Training Set

### Simple Explanation

  **Training set** is the portion of the dataset used to train the Machine Learning model. The model learns patterns and relationships from the training data.

### Example

   📌 Student Placement Example

Suppose we have a dataset containing information about **10,000 students**. We may use:

**8,000 students → Training Set**

The model learns the relationship between:

- IQ
- CGPA
- Study Hours
- Internship Experience

and the target: **Placement**.

  graph LR A\["📊 Training Data"\] B\["⚙️ ML Algorithm"\] C\["🧠 Learned Model"\] A --> B B --> C style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style C fill:#28a745,color:#fff,stroke:#333,stroke-width:4px  **Exam Definition:** The training set is the portion of a dataset used to learn the parameters and patterns of a Machine Learning model.   **Remember:** Training Set → **Learn**

---

## 2. Validation Set

### Simple Explanation

  **Validation set** is a separate portion of data used during model development to compare models, tune hyperparameters, and make decisions about the learning process.

### Why Do We Need Validation Data?

Suppose we are using a KNN model. We need to decide the value of **K**. For example:

- K = 3
- K = 5
- K = 7
- K = 9

We can use validation data to compare these choices and select a suitable configuration.

 graph TD A\["🏋️ Training Set"\] B\["🧠 Train Model"\] C\["⚙️ Validation Set"\] D\["🔧 Tune Hyperparameters"\] E\["🤖 Improved Model"\] A --> B B --> E E --> C C --> D D --> B style A fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style B fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style E fill:#28a745,color:#fff,stroke:#333,stroke-width:4px   📌 Example

Suppose we train a model with different learning rates:

| Learning Rate | Validation Accuracy |
| --- | --- |
| 0.1 | 84% |
| 0.01 | 91% |
| 0.001 | 87% |

The validation results help us decide which configuration works better during model development.

   **Exam Definition:** The validation set is a portion of data used during model development for hyperparameter tuning, model selection, and performance comparison.   **Remember:** Validation Set → **Tune / Select**

---

## 3. Test Set

### Simple Explanation

  **Test set** is a separate portion of data used for the final evaluation of the trained model. It should not be used to repeatedly tune the model.  graph LR A\["🤖 Final Model"\] B\["🧪 Unseen Test Data"\] C\["📊 Final Performance"\] A --> B B --> C style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style C fill:#28a745,color:#fff,stroke:#333,stroke-width:4px

### Example

   📌 Example

Suppose a dataset contains **10,000 samples**. After training and validation, we keep a separate test set.

**Test Set = 1,000 samples**

After the model and its configuration have been finalized, we evaluate it on these 1,000 unseen samples.

   **Exam Definition:** The test set is a separate portion of data used to provide an unbiased final evaluation of a trained Machine Learning model.   **Remember:** Test Set → **Final Evaluation**

---

## 4. Why Is Dataset Splitting Required?

### Simple Explanation

If we train and evaluate a model on exactly the same data, the evaluation may not represent how the model performs on new, unseen data. A model could simply become very good at the examples it has already seen. Therefore, we separate the data.

 graph TD A\["📊 Complete Dataset"\] A --> B\["🏋️ Training"\] A --> C\["⚙️ Validation"\] A --> D\["🧪 Testing"\] B --> E\["Learn Patterns"\] C --> F\["Tune Model"\] D --> G\["Evaluate on Unseen Data"\] E --> H\["Generalization"\] F --> H G --> H style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style H fill:#28a745,color:#fff,stroke:#333,stroke-width:4px

### Main Reasons for Splitting Data

- To train the model using one portion of the data.
- To tune hyperparameters and compare models.
- To evaluate the final model on unseen data.
- To estimate how well the model may generalize to new data.
- To reduce the risk of evaluating the model only on data it has already seen.

  **Important:** A Machine Learning model should perform well not only on training examples but also on new, unseen examples. This ability is called **generalization**.

---

## 5. Common Train / Validation / Test Ratios

There is no single train-validation-test ratio that is correct for every Machine Learning problem. The appropriate split depends on factors such as dataset size, problem type, and available data.

### Common Examples

| Training | Validation | Testing |
| --- | --- | --- |
| 70% | 15% | 15% |
| 80% | 10% | 10% |
| 80% | 20% | — |
| 90% | 5% | 5% |

   📌 Example: 10,000 Samples

Using an **80 / 10 / 10** split:

Training = 8,000 samples

Validation = 1,000 samples

Testing = 1,000 samples

  pie title Example: 80 / 10 / 10 Data Split "Training" : 80 "Validation" : 10 "Testing" : 10  **Exam Point:** 80/20 is a common train/test split when a separate validation set is not explicitly maintained. For a three-way split, examples include 70/15/15 and 80/10/10. These are examples, not universal rules.

---

## 6. Data Leakage

### Simple Explanation

  **Data leakage** occurs when information that should not be available to the model during training is unintentionally used during model development, causing overly optimistic evaluation results.

### Simple Example

   📌 Example: Test Data Leakage

Suppose you have:

- Training Data
- Validation Data
- Test Data

You repeatedly check the test-set performance while changing your model and hyperparameters.

Eventually, your decisions start being influenced by the test set.

Now the test set is no longer acting as a clean final evaluation set.

  graph TD A\["📊 Complete Dataset"\] A --> B\["🏋️ Training"\] A --> C\["⚙️ Validation"\] A --> D\["🧪 Test"\] B --> E\["🧠 Model"\] C --> F\["🔧 Tuning"\] F --> E D --> G\["📊 Final Evaluation"\] E --> G G -. "❌ Repeated tuning using test results" .-> F style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style E fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style F fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:3px

### Another Important Example: Preprocessing Leakage

Suppose you want to standardize your entire dataset. A common mistake is to calculate the mean and standard deviation using the complete dataset before splitting it. This allows information from validation/test samples to influence the transformation used for training.

A safer approach is:

 graph TD A\["📊 Raw Dataset"\] A --> B\["✂️ Split Data"\] B --> C\["🏋️ Training Data"\] B --> D\["🧪 Validation / Test Data"\] C --> E\["Calculate Preprocessing Parameters"\] E --> F\["Apply Transformation to Training"\] E --> G\["Apply Same Learned Transformation to Validation/Test"\] style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style E fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style F fill:#28a745,color:#fff,stroke:#333,stroke-width:3px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:3px  **Exam Definition:** Data leakage occurs when information from outside the appropriate training process becomes available to the model during training or model development, leading to misleadingly good evaluation results.   **Remember:** Data Leakage → **Information leaks into the learning process**

---

## 7. Training vs Validation vs Test Set

| Set | Main Purpose | Used During | Easy Word |
| --- | --- | --- | --- |
| **Training** | Learn model parameters and patterns | Training | **Learn** |
| **Validation** | Tune hyperparameters and compare model configurations | Model development | **Tune** |
| **Test** | Final evaluation on unseen data | After model decisions are finalized | **Evaluate** |

  **Easy Trick:**

 Training → **Learn**

 Validation → **Tune**

 Testing → **Final Check**

---

## 8. Complete Train-Validation-Test Workflow

 graph TD A\["📊 Complete Dataset"\] A --> B\["✂️ Split Dataset"\] B --> C\["🏋️ Training Set"\] B --> D\["⚙️ Validation Set"\] B --> E\["🧪 Test Set"\] C --> F\["🧠 Train Model"\] F --> G\["🤖 Candidate Model"\] G --> D D --> H\["🔧 Tune Hyperparameters"\] H --> F G --> I\["🔒 Finalize Model"\] I --> E E --> J\["📊 Final Test Evaluation"\] J --> K\["🎯 Estimate Generalization"\] style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style D fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style E fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style F fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style H fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style I fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style J fill:#28a745,color:#fff,stroke:#333,stroke-width:3px style K fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px

---

## 9. Real-Life Example

### Imagine Preparing for an Exam

   📚 Think of Machine Learning Like Exam Preparation

Imagine you have 1,000 practice questions.

**Training Set:** You study and practice 800 questions.

**Validation Set:** You use 100 questions to check your preparation and decide which topics or study strategies need improvement.

**Test Set:** You finally attempt 100 questions that you have kept aside for the final assessment.

The idea is similar in Machine Learning:

- Training → Learn
- Validation → Improve / Tune
- Testing → Final evaluation

   **Easy Analogy:**

 Training Set = **Study Material / Practice**

 Validation Set = **Mock Test for Improvement**

 Test Set = **Final Exam**

---

## 10. Quick Revision for Exams

**Training Set:** Used to learn model parameters and patterns.

**Validation Set:** Used for model selection and hyperparameter tuning.

**Test Set:** Used for final evaluation on unseen data.

**Why Split Data?** To train, tune, and evaluate the model separately.

**Common Ratios:** Examples include 80/20 for train/test and 70/15/15 or 80/10/10 for train/validation/test.

**Data Leakage:** Occurs when inappropriate information from outside the training process influences model learning or evaluation.

## 11. One Diagram to Remember Everything

 graph TD A\["📊 DATASET"\] A --> B\["🏋️ TRAIN SET"\] A --> C\["⚙️ VALIDATION SET"\] A --> D\["🧪 TEST SET"\] B --> E\["Learn Parameters"\] C --> F\["Tune Hyperparameters"\] E --> G\["🤖 MODEL"\] F --> G G --> H\["🔒 Finalize Model"\] H --> D D --> I\["📊 Final Evaluation"\] I --> J\["🎯 Generalization Performance"\] K\["⚠️ DATA LEAKAGE"\] K -.-> B K -.-> C K -.-> D style A fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style B fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style C fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style D fill:#e91e63,color:#fff,stroke:#333,stroke-width:3px style E fill:#005cbf,color:#fff,stroke:#333,stroke-width:3px style F fill:#ff9800,color:#fff,stroke:#333,stroke-width:3px style G fill:#28a745,color:#fff,stroke:#333,stroke-width:4px style H fill:#28a745,color:#fff,stroke:#333,stroke-width:3px style I fill:#6f42c1,color:#fff,stroke:#333,stroke-width:3px style J fill:#28a745,color:#fff,stroke:#333,stroke-width:3px style K fill:#dc3545,color:#fff,stroke:#333,stroke-width:3px

## Conclusion

Splitting data is one of the fundamental steps in a Machine Learning workflow. The key idea is:

  **Training → Learn

 Validation → Tune

 Testing → Final Evaluation**

A good Machine Learning workflow keeps the test set separate from model-development decisions and takes care to avoid **data leakage**.

  **Next Topic:** Feature Engineering and Feature Scaling in Machine Learning

## Training, Validation & Test Data in Machine Learning Quiz

1. What is the main purpose of the training set in Machine Learning?

- To perform the final evaluation
- To learn patterns and model parameters from data
- To select the test set
- To calculate only the accuracy

    The training set is the data from which the model learns.    [Discuss it](#)

Explanation

The training set is used to train the Machine Learning model by learning patterns and model parameters from the available data.

2. What is the main purpose of a validation set?

- To train the model parameters only
- To permanently store predictions
- To tune hyperparameters and compare model configurations
- To replace the training set

    Validation data is used during model development rather than as the final evaluation.    [Discuss it](#)

Explanation

The validation set is used for hyperparameter tuning, model selection, and comparing different model configurations during development.

3. What is the primary purpose of the test set?

- To repeatedly tune hyperparameters
- To train model parameters
- To perform the final evaluation on unseen data
- To increase the training dataset

    The test set should be kept separate until the model development decisions are finalized.    [Discuss it](#)

Explanation

The test set is used for the final evaluation of a trained and finalized model on data that was not used during model development.

4. Why is a dataset split into training, validation, and test sets?

- To make the dataset smaller
- To train, tune, and evaluate the model separately
- To remove all features
- To avoid using Machine Learning algorithms

    Each subset has a different role in the Machine Learning workflow.    [Discuss it](#)

Explanation

Dataset splitting allows the model to learn from training data, tune decisions using validation data, and receive a final evaluation using unseen test data.

5. Which dataset is primarily used to learn the parameters of a Machine Learning model?

- Training set
- Validation set
- Test set
- Production set

    The model learns its parameters from the data used during training.    [Discuss it](#)

Explanation

The training set is used to learn the model parameters and patterns from the data.

6. Which of the following is a common train/test split when a separate validation set is not used?

- 50/50
- 60/40
- 80/20
- 99/1

    80/20 is a commonly used example of a train/test split.    [Discuss it](#)

Explanation

An 80/20 split is a common example where 80% of the data is used for training and 20% for testing. The appropriate ratio depends on the problem and dataset.

7. Which is an example of a three-way train/validation/test split?

- 70/15/15
- 30/30/40
- 50/10/40
- 95/10/5

    The three percentages should add up to 100%.    [Discuss it](#)

Explanation

70/15/15 is a valid three-way split: 70% training, 15% validation, and 15% testing. Other splits such as 80/10/10 can also be used.

8. A dataset contains 10,000 samples. Using an 80/10/10 split, how many samples are used for testing?

- 100
- 500
- 1,000
- 8,000

    10% of 10,000 is 1,000.    [Discuss it](#)

Explanation

With an 80/10/10 split, 10% of 10,000 samples are assigned to the test set, which equals 1,000 samples.

9. What does generalization mean in Machine Learning?

- The ability to memorize the training data
- The ability to perform well on new, unseen data
- The ability to increase the dataset size
- The ability to remove validation data

    A model should work beyond the examples it has already seen.    [Discuss it](#)

Explanation

Generalization is the ability of a Machine Learning model to perform well on new, unseen data rather than only on its training examples.

10. What is data leakage?

- Removing duplicate rows from a dataset
- Using inappropriate information during training or evaluation that should not be available
- Splitting data into training and testing sets
- Reducing the number of features

    Leakage occurs when information that should remain unavailable influences model learning or evaluation.    [Discuss it](#)

Explanation

Data leakage occurs when information from outside the appropriate training process becomes available to the model during training or development, often producing overly optimistic evaluation results.

11. Which situation is an example of data leakage?

- Training a model using only the training set
- Evaluating the finalized model once on the test set
- Repeatedly changing the model based on test-set performance
- Splitting the dataset before training

    The test set should not repeatedly influence model-development decisions.    [Discuss it](#)

Explanation

Repeatedly using test-set results to change the model or hyperparameters causes information from the test set to influence development, which compromises its role as an unbiased final evaluation.

12. What is a common form of preprocessing data leakage?

- Fitting a scaler only on the training data
- Calculating preprocessing statistics using the complete dataset before splitting
- Applying the trained scaler to test data
- Removing missing values from training data

    Preprocessing parameters should be learned from training data rather than from the complete dataset.    [Discuss it](#)

Explanation

Calculating preprocessing statistics such as mean and standard deviation using the complete dataset before splitting can allow information from validation or test data to influence the training process.

13. How should a scaler generally be used to avoid preprocessing leakage?

- Fit it separately on the test set
- Fit it on the complete dataset
- Fit it on the training data and apply the learned transformation to validation/test data
- Fit it only on the target variable

    The training data should be the source of preprocessing parameters.    [Discuss it](#)

Explanation

The scaler should be fitted using the training data, and the same learned transformation should then be applied to validation and test data.

14. Which dataset should generally remain untouched while selecting hyperparameters?

- Training set
- Validation set
- Test set
- All datasets equally

    The test set is reserved for the final evaluation after development decisions are complete.    [Discuss it](#)

Explanation

The test set should generally remain untouched during model selection and hyperparameter tuning so it can provide a more unbiased final evaluation.

15. What can happen if the test set is used repeatedly for hyperparameter tuning?

- The test set becomes completely independent
- The model may indirectly overfit to the test set
- The training set becomes larger
- Data leakage becomes impossible

    Repeatedly making decisions based on test results allows information from the test set to influence development.    [Discuss it](#)

Explanation

Repeatedly using test-set results for tuning can cause the model-development process to overfit to the test set, making the final evaluation less reliable.
