Training, Validation and Test Sets: How To Split Machine Learning Data

A concise explanation of the differences between ML training, validation and test sets | How to include enough data to train machine learning models.

Training, Validation and Test Sets: How To Split Machine Learning Data

In machine learning (ML), a fundamental task is the development of algorithm models that analyze scenarios and make predictions. During this work, analysts fold various examples into training, validation, and test datasets. Below, we review the differences between each function.

Train vs. validate vs. test

Training datasets comprise samples used to fit models under construction, i.e., carry out the actual AI development. Constructing these robust pillars of AI involves following best practices.

In contrast, validation datasets contain different samples to evaluate trained ML models. It is still possible to tune and control the model at this stage.

A test dataset is a separate sample to provide an unbiased final evaluation of a model fit. The inputs are similar to the previous stages but not the same data.

Datasets used to train and validate can play additional roles in model preparation, such as selecting optional features. The fit of the final model is a combined result from the aggregate of these inputs.

Training sets

Initially, the development method involves initial inputs within specified project parameters. The process also requires the expert setting of weightings between the various connections of so-called neurons within the ML model or estimator*.

After the introduction of this first dataset, developers compare the resulting output to target answers. Next, they adjust the model's parameters, weighting, and functionality, as needed.

More than one epoch or iteration of this adjustment loop is often necessary. The goal is to achieve a trained or fitted model that relates to and corresponds with the expected range of new, unknown data.

Validation sets

The next stage involves using a validation dataset to estimate the accuracy of the ML model concerned. During this phase, developers ensure that new data classification is precise and results are predictable.

Validation datasets comprise unbiased inputs and expected results designed to check the function and performance of the model. Different methods of cross-validation (CV) exist, though all aim to ensure stability by estimating how a predictive model will perform. An example is the usage of rotation estimation or out-of-sample testing to assure reasonable precision.

Resampling and fine-tuning involve various iterations. Whatever the methodology, these verification techniques aim to assess the results and check them against independent inputs. It is possible also to adjust the hyperparameters, i.e. the values used to control the overall process.

Some experts consider that ML models with no hyperparameters or those that do not have tuning options do not need a validation set.

Test sets

The final step is to use a test set to verify the model's functionality. Some publications refer to the validation dataset as a test set, especially if there are only two subsets instead of three. Similarly, if records in this final test set have not formed part of a previous evaluation or cross-validation, they might also constitute a holdout set.

Test samples provide a simulated real-world check using unseen inputs and expected results. In practice, there could be some overlap between validation and testing. Each procedure shows that the ML model will function in a live environment once out of testing.

The difference is that while validating, the results provide metrics as feedback to train the model better. In contrast, the performance of a test procedure merely confirms that the model works overall, i.e. as a black box with inputs passed through it. During this final evaluation, there is no adjustment of hyperparameters.

Get started

Learn more!

Discover how training data can make or break your AI projects, and how to implement the Data Centric AI philosophy in your ML projects.

How to split your machine learning data

Above, we have seen the distinction between the different types of sets. The next decision is splitting enough data between each of them.

The optimum ratio when dividing records with enough data between each function – train, validate and test – depends on the application usage, model type, and data dimensions. Most ML models benefit from having a substantial number of scenarios from which to train.

At the validation stage, models with few or no hyperparameters are straightforward to validate and tune. Thus, a relatively small dataset should suffice.

In contrast, models with multiple hyperparameters require enough data to validate likely inputs. CV might be helpful in these cases, too. Generally, apportioning 80 percent of the records to train, 10 percent to validate, and 10 percent to test scenarios ought to be a reasonable initial split.

Common pitfalls in the training data split

A validation dataset must not be too small. Otherwise, the ML model will be untuned, imprecise, or even inaccurate. In particular, the F1 score – a statistical measure of precision and recall – will vary too widely.

One cycle through a complete dataset in artificial neural networks is an epoch. Perhaps unsurprisingly, training a model usually takes more than one epoch.

The train-test-validation ratio depends on the usage case. Getting the procedure right comes with experience.


An alternative approach involves splitting an initial dataset into two halves, training, and testing. Firstly, with the test set kept to one side, a proportion of randomly chosen training data becomes the actual training set. The remaining values in the array are for later iterations to validate inputs. As an example, the split might vary from two halves to a ratio of 80:20 percent.

This cross-validation or CV involves one or more splits of the training and validation data. In particular, K-fold cross-validation aims to maximize accuracy in testing by dividing the source data into several bins or groups. All except one of these are for training and validation purposes. The last is for testing.

In this method, each set runs as a separate experiment. Analysts then calculate the average of all the runs to obtain the mean accuracy. Once the result falls within specified limits, the final step before signoff is to use the single remaining fold of test data to double-check the findings.

Low-quality training data

Like other areas of IT, machine learning algorithms follow the time-tested principle of GIGO: garbage in, garbage out. So, to ensure reliable and robust algorithms, the following three components are necessary:

  • Quantity. Sufficient data is important for the model to learn how to interact with users. As an analogy, humans need a considerable amount of information before becoming an expert.

  • Quality. In themselves, data will not guarantee reliable results. Real-world scenarios and test cases that represent likely conditions are vital. Data should mimic the user input that the new algorithm will receive. It is essential to fold in data on which the application will rely, such as a combination of images, videos, sounds, and voices.

  • Diversity. ML requires algorithms trained on more than one input fold to simulate most if not all likely and possible cases.

Designers should seek to prevent bias in models. Applications must comply with legislation and should conform with inclusivity guidelines. They should not display prejudice based on age, race, gender, language, marital status, or other identifying factors.


When developing an ML model, an essential principle is that validation and test datasets must remain separate. Otherwise, an overfit might occur. Overfitting is when exceptional or unreal conditions lead to incorrect outputs. In other words, the statistical model fits precisely with the inputs used to train it and will probably not be accurate.

Instead, the aim should be to generalize. The proper application of CV ought to minimize overfitting and ensure that the algorithm's prediction and classification functionality are correct.

Overemphasis on validation and test set metrics

Overfitting can also arise if development methodology overuses search techniques to look for empirical relationships in the input samples. This approach tends to identify relationships that might not apply in the real world.

As an analogy, it is akin to looking for connections that do not exist between random events. Nonetheless, discerning between occasional coincidences and the emergence of new patterns does involve a delicate balancing act, with careful evaluation of the probabilities involved.

Although validation datasets contain different data, it is essential to remember that evaluations should not be too lengthy. Otherwise, the model tends to become more biased as validation data perfuses into the configuration.

Training, validation & test sets: Key takeaways

Quality is paramount for AI to deliver accurate results in the ingenious and expanding field of ML. Sound predictions and stable system behavior require the correct application of various key principles.

Essential considerations when organizing data for test sets are that:

  • Training data builds the ML algorithm. Analysts feed in information and look for corresponding expected outputs. The import should be within specification and sufficient in quantity.

  • When validating, it is necessary to use fold in unseen values. Here, the new inputs and outputs enable ML designers to evaluate how accurate the new model's predictions are.

  • Overfitting can result from too much searching or excessive amounts of validation data.

  • While supervised ML approaches use a tag or classifier to identify training records, test records must remain untagged. Same data labels could enable the ML model to single out a shared reference, leading to anomalies in the results.

Get started

Pro tip πŸ’‘

Discover how to automate your data labeling to increase the productivity of your labeling teams! Dive into model-in-the-loop, active learning, and implement automation strategies in your own projects.

Craft better ML algorithms

In today's busy manufacturing and service industries, ML enables businesses to fold reams of raw detail into insightful predictions. In turn, better management brings about organic growth and increased revenue.

Kili is today's complete solution to fold input, achieve optimum CV, iterate smoothly, and train AI successfully. Moreover, it enables companies and public organizations to make the most of the latest ML and data visualization techniques.

Because Kili works equally well with computer vision, i.e. images and video, it enables you to manage algorithm development better. This new platform accepts voice, text, and PDF file inputs. It supports NLP and OCR applications, too.

Available online or on-premise to match all requirements, the impressive feature list includes rapid annotation, simple collaboration, quality control, project management, and tutorial support. Increasingly, today's forward-looking CTOs, data lab managers, and technical CXOs are shortlisting this innovative solution. To discover more, see an example or arrange a demonstration, we invite you to contact our specialist team today.

Continue reading
Get started

Get Started

Get started! Build better data, now.