Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Test Data

Test data is a held-out split scored once, after all training and tuning, to estimate performance on new data. Splits, sizing, pitfalls, and code.

Test data, also called the test set or holdout set, is the portion of a dataset reserved for measuring a finished machine learning (ML) model. It plays no part in fitting the model weights or in any development decision, such as the architecture, hyperparameters, checkpoint, or confidence threshold, and it is scored once those decisions are final. Because the model and its developers have never adapted to it, its accuracy, recall, or mean average precision (mAP) is an unbiased estimate of how the model will perform on new data from the same distribution, the number teams use to decide whether a model is ready for deployment.

Training, Validation, and Test Splits#

A dataset is usually divided into three disjoint splits with different jobs:

  • Training data: The examples the optimizer learns from, adjusting weights to reduce the loss.
  • Validation data: Scored repeatedly during development to compare hyperparameters, stop training early, and choose the best checkpoint.
  • Test data: Scored once at the end to report the metric the project is judged on.

Splits of 80/10/10 or 70/15/15 are common for datasets of thousands of examples, while datasets of millions can hold out a few percent. The size a test set needs depends on the precision required: the standard error of an accuracy p measured on n examples is the square root of p(1 − p)/n, so 1,000 test images at 90% accuracy give a 95% confidence interval of about ±1.9 percentage points, and 10,000 images narrow it to about ±0.6. Naming varies across fields, and many papers report their final ImageNet results on the official validation set because the ImageNet test labels are not public. In Ultralytics YOLO, a dataset YAML requires train and val paths and accepts an optional test path; training scores val after every epoch to pick best.pt, and model.val(data="data.yaml", split="test") scores the finished model on the held-out images in validation mode.

Why the Test Set Must Stay Untouched#

Every decision made by looking at a score fits that data a little. When many configurations compete on the validation set, the winner is partly the one that got lucky on those particular examples, so its validation score overstates how it performs elsewhere. The following scikit-learn experiment picks the best neighbor count for a k-nearest neighbors classifier on a small, noisy dataset and compares the winner's validation and test accuracy over 30 random datasets:

import numpy as np
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

val_scores, test_scores = [], []
for seed in range(30):
    # A small, noisy dataset split 60/20/20 into train, validation, and test
    X, y = make_classification(n_samples=400, n_features=20, n_informative=4, flip_y=0.2, random_state=seed)
    X_train, X_rest, y_train, y_rest = train_test_split(X, y, test_size=0.4, random_state=seed)
    X_val, X_test, y_val, y_test = train_test_split(X_rest, y_rest, test_size=0.5, random_state=seed)

    # Model selection: keep the neighbor count with the best validation accuracy
    scores = {k: KNeighborsClassifier(k).fit(X_train, y_train).score(X_val, y_val) for k in range(1, 51)}
    best_k = max(scores, key=scores.get)
    val_scores.append(scores[best_k])

    # The test set is scored once, after the choice is final
    test_scores.append(KNeighborsClassifier(best_k).fit(X_train, y_train).score(X_test, y_test))

print(f"Chosen model, mean of 30 runs: validation {np.mean(val_scores):.3f}, test {np.mean(test_scores):.3f}")

The chosen models average 0.805 on validation and 0.758 on test, so selecting among 50 candidates inflated the validation estimate by almost five points. Tuning against the test set would hide that gap and carry the same optimism into the reported result, a form of data leakage. Public benchmarks guard against it by withholding labels: COCO test-dev results come from submitting predictions to an evaluation server. For large language models (LLMs), test questions that appear in web-scale pretraining data contaminate a benchmark, which is why LiveCodeBench keeps adding new contest problems and scores each model on problems published after its training cutoff.

Building a Reliable Test Set#

A test score predicts real-world performance only when the test set resembles the data the model will meet, whether that is street scenes for autonomous vehicles or scans for medical image analysis:

  • Match deployment conditions: Cameras, lighting, seasons, geography, and class balance should reflect production. A driving detector needs night, rain, and snow scenes in its test set even if most driving happens in clear weather.
  • Keep it independent: Frames from the same video, scans of the same patient, and photos of the same scene belong in one split. Time-ordered data is split by date, so the model is tested on the future.
  • Test across sources: In medical imaging, external validation on scans from other hospitals and scanner models shows whether a model learned anatomy or one site's equipment.
  • Clean the labels: Errors in test labels cap the measurable accuracy and can reorder models, so test labels deserve the most careful review.
  • Report slices: Per-class and per-condition metrics expose failures that a single average hides.

Even a carefully rebuilt test set can shift results: when researchers recreated the ImageNet test set following the original collection process, accuracy fell by 11 to 14 percentage points across a broad range of models, although gains on the original test set carried over, and the authors attributed the drop to slightly harder images rather than to years of test set reuse.

  • Cross-validation: Rotates which part of the development data serves as validation, giving a steadier estimate for model selection. A separate test set still provides the final number.
  • Benchmark dataset: A public test set shared across a research field. Because every team evaluates on it for years, it gradually stops being unseen data.
  • Golden dataset: A curated, high-quality reference set with checked answers, often used as a fixed test set for regression testing of LLM applications.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning