Book a free call

Evaluating Machine Learning Models: What to Measure

Evaluating machine learning models means testing on unseen data with the right metrics. This guide covers data splits, precision and recall, and drift checks.

Hertiv engineering teamReviewed by a senior engineer
5 min read
Evaluating Machine Learning Models: What to Measure
On this page

Short answer

Evaluating a machine learning model means measuring how it performs on data it has never seen, using metrics that match the cost of each error. Split data without leaking test information, report precision, recall and calibration at the threshold you will ship, check errors by group, and re-evaluate on fresh data after launch.

What does evaluating a machine learning model mean?

Evaluating a machine learning model means measuring how well it performs on data it has never seen, so you know whether it will work in production rather than only on the data it was trained on. A model that scores well on its training data and fails on new data is memorising, not learning.

Evaluation has three parts: splitting data so the test set stays untouched, picking metrics that match the decision the model supports, and checking errors by group so a good average does not hide a bad result for one kind of input. Each part is simple, but skipping any of them leads to surprises after launch. The basics of the field are covered in what machine learning is.

Good evaluation is a habit, not a one-off task. You evaluate before launch, after every retraining, and on a schedule once the model is live, because data changes over time.

How do you split data for evaluation?

You split data for evaluation by holding out a test set the model never sees during training, and by using cross-validation when the data set is small. The split must respect time and grouping, or the score will flatter the model.

Use the table to pick a method. The key rule is that no information from the test set may leak into training, including through feature scaling or feature selection done on the full data.

Method What it does When to use it
Train and test split Holds out one test set Large data sets, quick checks
Cross-validation Rotates the test fold Small data sets, stable scores
Time-based split Tests on later data only Time-ordered data, forecasting
Group split Keeps groups together Repeated users or devices

For time-ordered data, always test on later data. A random split on sales or sensor data lets the model peek at the future, which makes the score meaningless.

Which metrics should you measure?

You should measure the metrics that match the cost of each kind of error, because accuracy alone hides the errors that matter. For a fraud model, missing fraud costs far more than a false alarm, so recall matters more than accuracy.

The metrics most teams need are:

  • Precision. Of the items the model flagged, how many were right. High precision means few false alarms.
  • Recall. Of the real cases, how many the model found. High recall means few misses.
  • F1 score. The balance of precision and recall in one number, useful when both matter.
  • ROC-AUC. How well the model ranks positive cases above negative ones across thresholds.
  • Calibration. Whether a predicted probability of 80% is right about 80% of the time.

Pick a threshold deliberately. A model outputs scores, and the threshold turns scores into decisions; changing it trades false alarms against misses. Report metrics at the threshold you will actually ship. Language models need extra checks on top of these, which LLM model evaluation covers in detail.

How do you check errors by group?

You check errors by group by breaking the test results down by the slices that matter to your product, such as customer type, region, device or time of day. A model with 95% accuracy overall can still fail badly for one group, and the average will not show it.

Start with the slices your team already worries about: new users, rare categories, edge-case inputs and the group that generates the most complaints. For each slice, report the same metrics you report overall, and set a minimum acceptable level before launch.

Confusion matrices help here. They show which classes the model confuses with each other, which often points at a labelling problem or a missing feature rather than a modelling problem. Fix the data first when the confusion is systematic.

How do you keep a model honest after launch?

You keep a model honest after launch by re-evaluating it on fresh labelled data, watching for drift in inputs and outputs, and retraining on a schedule. Data changes, and a model that was good six months ago can quietly get worse as customer behaviour shifts.

Set up three checks: input drift, which compares new inputs with training data; output drift, which watches the share of each prediction; and a labelled sample, where a person checks a small set of live predictions each week. When any of them moves past a threshold you set in advance, investigate before retraining.

Log every prediction with its inputs and the model version, so you can replay a bad week and find what changed. Without logs, a drop in quality is a mystery instead of a diagnosable problem. Teams that need help building this pipeline can look at machine learning development services.

Example (hypothetical): a support team checks a spam filter

Example (hypothetical): a support team tests a spam filter on 1,000 held-out messages, of which 100 are spam and 900 are genuine. The model flags 90 messages as spam, and 80 of those are truly spam.

Precision is 80 out of 90, about 89%, so roughly one in nine flagged messages is a false alarm. Recall is 80 out of 100, or 80%, so the model misses 20 spam messages. The team also finds 10 genuine messages flagged as spam, which is the cost of the false alarms.

The team decides 80% recall is too low for their inbox, so it lowers the threshold. The model then catches 90 of the 100 spam messages, but flags 30 genuine ones. Recall rises to 90% while precision falls to 75%, and the team accepts that trade because missed spam costs more than a few extra checks.

What are the common mistakes?

The most common model evaluation mistakes are testing on training data, picking the wrong metric, and never re-evaluating after launch.

  • Testing on training data. Scores on data the model memorised say nothing about new data.
  • Reporting accuracy only. Accuracy hides the errors that cost money, especially on imbalanced data.
  • Leaking the test set. Scaling features or selecting features on the full data leaks test information into training.
  • Ignoring slices. A good average can hide a failing group that generates the most complaints.
  • No retraining plan. A model left unevaluated for a year will drift silently as data changes.

Key takeaways

  • Never test on training data; hold out a test set the model has never seen
  • Pick metrics by error cost, not by habit, and report them at the shipped threshold
  • Break results down by group so a good average does not hide a failing slice
  • Respect time and grouping when splitting data, or the score will flatter the model
  • Re-evaluate on fresh labelled data and watch for drift after launch

Frequently asked questions

What is the difference between validation and test data?

Validation data is used to tune the model and pick settings, while test data is used once at the end to estimate real performance. If you tune on the test set, it stops being an honest measure and your scores will look better than reality.

Is accuracy a good metric for machine learning models?

Accuracy is only useful when classes are balanced and all errors cost the same. On imbalanced data, such as fraud detection, a model can score 99% accuracy by predicting the majority class every time. Precision, recall and calibration say more.

How much test data do you need?

It depends on how rare the event you care about is. You need enough positive cases in the test set for the metrics to be stable, often hundreds at least. With very rare events, collect more test data rather than trusting a score from a handful of cases.

What is data leakage in model evaluation?

Data leakage happens when information from the test set influences training, for example by scaling features on the full data set or by including a feature that is only known after the outcome. Leaked models score well in testing and fail in production.

How often should you re-evaluate a model?

Re-evaluate after every retraining and on a regular schedule once live, such as monthly for fast-changing data. Also re-evaluate whenever inputs change, for example after a product update or a shift in customer behaviour.

How is evaluating a machine learning model different from evaluating an LLM?

The principles are the same, but LLM evaluation adds task-specific checks such as factual accuracy, format compliance and benchmark scores. This guide covers the general machine learning case, while LLM guides cover those extra checks in detail.

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 machine learning product and need help measuring it? 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