blog / machine learning

The one number to ask for before you trust a machine learning model

Accuracy on training data tells you almost nothing. Here is what to ask for instead, and how to spot results that will not survive real use.

When someone shows you a machine learning model, they will usually show you a number: 95% accuracy, an R² of 0.98, an error of a few percent. The number may well be real. The question that decides whether it means anything is simple to ask and surprisingly often left unanswered: measured on what data?

Training scores flatter every model

A model is fitted to its training data. Given enough flexibility, it can learn that data almost perfectly, including its noise and coincidences. A score measured on the same data it learned from is a measure of memory, not of skill. It tells you nothing about how the model will do on the next customer, the next scan or the next rock sample.

That is why the number worth asking for is performance on a held-out test set: data that was set aside before modelling started and never used to train or tune the model. It is the closest thing you can get, before launch, to the real world.

How we keep the test honest

Setting data aside is only half of the job. A test set stays trustworthy only if nothing about it leaks into the work. On every project we follow the same rules.

  • Lock the split first. Training, validation and test sets are fixed before any modelling. The split is saved, so every experiment is measured on exactly the same examples.
  • Tune on validation, never on test. Choosing settings by checking the test score, even informally, slowly turns the test set into training data.
  • Prepare data inside the training fold. Scaling, filling missing values and feature selection are learned from training data only, then applied to the test set.
  • Compare against a fair baseline. A score means more next to a simple model, or a published method reproduced on the same split.

On our dynamic rock-strength project, for example, the splits were locked before modelling began. On the untouched test specimens, the selected model reached an R² of 0.992, against 0.900 for the published model we reproduced on the same split. Both numbers come from the same unseen data, which is what makes the comparison mean something.

Data leakage: the quiet way results go wrong

Leakage happens when information about the answer sneaks into the model's inputs. It produces beautiful scores that collapse in production. Common causes include duplicate records appearing in both training and test data, features that are only known after the outcome happened, and time-ordered data split at random so the model effectively sees the future.

Leakage is not something only beginners run into. On our network intrusion detection research, an early leakage issue was found during review and fixed before results were reported. Finding it is a sign that the checking is working. Never looking for it is the real risk.

Five questions to ask about any model

  1. Was the score measured on data the model never trained on?
  2. When was that test data set aside, and was it ever used to choose settings?
  3. How does the model compare to a simple baseline on the same data?
  4. If the data is time-based, was the test set taken from a later period?
  5. What do the mistakes look like? Ask to see the confusion matrix or the largest errors, not just the average.

The takeaway

A model is only as trustworthy as the test it passed. Ask for performance on a held-out test set, ask how that set was protected, and ask to see the errors. Any team doing careful work will be glad you asked, and the answers will tell you more than any headline number.

NS

Neurals Solutions

A five-person software studio in Multan building web apps, mobile apps and machine learning systems.

Want a second opinion on a model's results?

Send us the numbers you have been shown and we will tell you what they do and don't prove.