Book a free call

Model Validation in Machine Learning: How to Know a Model Works

Model validation in machine learning means testing a trained model on data it has never seen, so you know how it will behave on new cases. Here is how to do it.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Model Validation in Machine Learning: How to Know a Model Works
On this page

Short answer

Model validation in machine learning is the process of testing a trained model on data it did not learn from, to measure how well it will perform on new cases. It is the step between training a model and trusting it, and it is what separates a model that memorised its training data from one that learned a pattern that holds up.

What is model validation in machine learning?

Model validation in machine learning is the process of testing a trained model on data it did not learn from, to measure how well it will perform on new cases. The model is trained on one set of examples, then scored on a separate set it has never seen, so the score reflects real behaviour rather than memory.

The reason is simple: a model can always be made to score well on the data it trained on, by memorising the answers. That score tells you nothing about the next case. Validation is the check that the model learned a pattern that holds beyond the examples it was shown.

Validation is not the same as testing the model in production. It happens before release, on held-out data, and its job is to catch problems while they are still cheap to fix. A model that fails validation goes back for more work; a model that passes it can be tested again on a final test set.

Why does a model need a separate validation set?

A model needs a separate validation set because every decision made while building it, from picking features to tuning settings, can quietly adapt the model to the training data. If those decisions are judged on the same data the model learned from, the score will look better than the model really is.

The split is usually three-way. The training set teaches the model. The validation set is used to compare versions and pick settings. The test set is kept aside and used once, at the end, to confirm the final model. Keeping the test set untouched is what makes the final number honest.

Without this split, teams ship models that look strong in development and fail on the first real cases. The failure is rarely obvious in the training score; it shows up as a model that is confident and wrong about cases it has not seen before.

What are the main validation methods?

The main validation methods are a hold-out split, k-fold cross-validation, stratified sampling, time-based splits and group splits. Each one fits a different kind of data, and the wrong choice can hide the very problem you are trying to catch.

Method How it works Best when Watch out for
Hold-out split One fixed split of train and validation Large data sets One unlucky split
K-fold cross-validation Data split into k parts, each used once as validation Small or medium data sets Longer run time
Stratified split Each split keeps the same class mix Rare outcomes Small classes still thin
Time-based split Train on past, validate on later data Data that changes over time Old patterns may not repeat
Group split Whole groups kept together in one split Data from many users or sites Groups differ in size

For data that changes over time, such as sales or support tickets, a random split is the wrong choice: it lets the model peek at the future. A time-based split is the honest one there.

For data grouped by customer or clinic, a group split stops the model from memorising one group and looking good on its other records. Choosing the split is part of the validation work, and how to evaluate an LLM application covers the same thinking for language models.

Which metrics should you check?

The metrics you should check depend on what a mistake costs. Accuracy alone is rarely enough, because it hides which kind of error the model makes, and the two kinds of error usually cost different amounts.

For classification, check precision and recall alongside accuracy. Precision is the share of the model's positive calls that were right; recall is the share of real positives it found. A fraud model with high precision but low recall misses most fraud, while one with high recall but low precision flags too many honest cases.

For ranking and scoring, check how the model orders cases, not just how many it gets right. For regression, check the size of the errors, not only their direction. And for any model, check the score per group that matters, such as per region or per product line, because a good average can hide a bad result for one group.

How do you validate a model, step by step?

You validate a model by splitting the data before training, choosing settings on the validation set, and confirming the final model once on a test set never used for any decision.

  1. Split before you look. Divide the data into training, validation and test sets before training anything, and keep the test set sealed.
  2. Pick the split method. Use a time-based split for data that changes over time, a group split for data from many users or sites, and a stratified split when an outcome is rare.
  3. Train on the training set only. The model must never see validation or test data during training, including features built from the whole data set.
  4. Compare versions on validation. Try different settings and pick the version with the best validation score, using the metrics that match what a mistake costs.
  5. Check the errors, not just the score. Read a sample of the cases the model got wrong and look for a pattern, such as one group failing.
  6. Confirm once on the test set. Score the final model on the sealed test set once. If the score drops far below validation, the model was tuned to the validation set.
  7. Set a re-check rule. Decide when the model will be validated again, such as monthly or when new data arrives, so drift is caught.

Teams that build models for production usually wrap these steps in a repeatable pipeline, which is where MLOps consulting helps: the split, scoring and re-check run the same way every time.

Example (hypothetical): a support-ticket classifier

Example (hypothetical): a support team builds a classifier that routes 10,000 past tickets into billing, technical and account groups. The team splits the data 70/15/15, giving 7,000 tickets for training, 1,500 for validation and 1,500 for testing.

The first version scores 86% on the validation set, which is 1,290 of the 1,500 tickets routed correctly. Reading the errors shows that billing tickets with the word 'refund' are often sent to the technical group, so the team adds a feature for refund language and retrains. The new version scores 91% on validation, or 1,365 of 1,500 correct, a gain of 75 tickets.

Only then does the team score the model on the sealed test set. It scores 90%, close to the validation result, which is the sign the model learned a pattern rather than the validation data. If the test score had dropped to 78%, the team would have known the tuning had overfit the validation set and gone back to step four.

What are the common mistakes?

The most common model validation mistakes are letting test data leak into training, tuning on the test set, and judging a model by one number.

  • Data leakage. A feature built from the whole data set, or a record that appears in both training and validation, lets the model peek at the answer.
  • Tuning on the test set. Every time a decision is made using the test score, the test set stops being an honest check.
  • Random splits for time data. Shuffling data that changes over time lets the model learn from the future and look better than it is.
  • One metric only. A single accuracy number hides which errors the model makes and which group it fails on.
  • Ignoring the error pattern. A score without reading the wrong cases leaves the fix unknown; the errors usually point at the missing feature.
  • No re-check plan. Data changes, so a model validated once and never checked again will drift silently.

If you are building a model for production, machine learning development covers the full path from data to a model you can trust.

Machine learning in healthcare shows how the same checks apply in a regulated setting.

Key takeaways

  • Validation tests a model on data it never trained on, so the score reflects new cases, not memory
  • Split the data three ways: training to teach, validation to compare versions, test to confirm once
  • Use a time-based split for data that changes over time and a group split for data from many users or sites
  • Check precision, recall and per-group scores, not accuracy alone
  • Read the errors the model makes, because they usually point at the missing feature

Frequently asked questions

What is the difference between validation and testing a model?

Validation is used during development to compare versions and pick settings, on a set the model did not train on. Testing is the final check, run once on a sealed set that was never used for any decision. Validation guides choices; testing confirms the final model.

How much data should go in the validation set?

A common split is 70% training, 15% validation and 15% test, but the right split depends on the size of your data. With a small data set, k-fold cross-validation uses the data better, because each part takes a turn as the validation set.

What is k-fold cross-validation?

K-fold cross-validation splits the data into k equal parts, then trains the model k times, each time holding out a different part as the validation set. The average score across the folds is a more stable estimate than a single split, and it works well when data is limited.

What is data leakage in model validation?

Data leakage happens when information from the validation or test set reaches the model during training, often through a feature built from the whole data set or a record that appears in both splits. The score then looks better than the model really is, and the problem only shows up on new data.

When should a model be re-validated?

Re-validate on a fixed schedule, such as monthly, and whenever the data changes, such as a new product, a new customer group or a shift in how cases arrive. A model that is never re-checked will drift as the world it was trained on changes.

Can a model pass validation and still fail in production?

Yes. Validation only checks the model against the data you held out, so it cannot catch problems the data does not show, such as a new kind of case or a change in how inputs are recorded. That is why production monitoring and a re-check rule matter as much as the first validation.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a model you need to trust in production? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Machine Learning Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call