Backtesting an inspection: proving it works before it ships

Fleet yield dashboard showing overall yield and a per-camera breakdown with one station running noticeably lower than the rest

The default way to find out whether an inspection works is to install it and watch. That is an expensive experiment, because the thing you are testing for is a defect reaching a customer, and you only learn the answer once it has.

Backtesting is the alternative. You assemble images whose true condition you already know, run the complete recipe over every one of them offline, and get your escape and overkill counts before the station gates a single real part. It is not a novel idea. It is what every other gauge on the floor goes through before it is trusted, and there is no reason an AI inspection should be exempt.

What a backtest actually does

The mechanics are simple enough to describe in a sentence: take a set of captures, label what each one truly is, run the live recipe across all of them, and compare the recipe's verdict against the label.

Two details make the difference between a real test and a demo. The first is that it runs the whole recipe, every model and every rule, not one model in isolation. A station usually fails at the seams: two models that each behave correctly and a verdict rule that combines them wrongly. Testing the models separately never finds that.

The second is that the output is a confusion matrix you can click into. A number telling you there were four escapes is a start. Being able to open those four images and see what they had in common is what lets you fix the cause instead of nudging a threshold until the number improves.

Building a test set that does not flatter you

This is where most validation goes wrong, and it goes wrong in a predictable direction. Left to themselves, people assemble obvious passes and obvious failures, because those are the parts that are easy to label confidently. The resulting numbers look excellent and do not survive contact with production.

Include the arguments

The parts your own inspectors disagree about are the most valuable images you have. They are where the real decision boundary sits. A test set without them measures the easy question.

Span the real variation

Different material lots, different shifts, the tooling near the end of its life as well as fresh. If the set came from one afternoon, it describes one afternoon.

Label by agreement, not by one person

Ground truth is a decision, not an observation. If two engineers label the marginal parts differently, that disagreement is a specification problem and it is better found now than after commissioning.

Keep it, and re-run it

A test set used once is a demo. Re-run after every recipe change, or you will tune one number while quietly breaking another. Test sets that travel between cameras as a file make that practical across a fleet.

A useful sanity check on any test set: if the recipe scores perfectly on the first run, the set is probably too easy rather than the recipe being perfect. Genuinely marginal parts produce a few disagreements, and those are the interesting ones.

Repeatability, and why quality teams ask for it

Accuracy on a single pass is not the same as trustworthiness. A station can be right on average and still be unusable if it gives different answers to the same part on different runs, because disposition depends on the answer you happened to get.

This is what a gauge repeatability and reproducibility study measures, and it is already routine for a caliper, a bore gauge or a coordinate measuring machine. Running it on a vision inspection means passing the same parts through more than once and comparing the verdicts. Where the results diverge, you have found either genuine borderline parts sitting exactly on the decision boundary, or a source of variation in the station itself: lighting that is not as fixed as everyone assumed, a part that seats differently, an exposure that drifts.

It is also a fair question to put to a vendor. Asking for gauge R&R on a vision system tells you quickly whether they have deployed into regulated manufacturing or whether they are going to send you a single accuracy percentage and hope.

Yield by station separates two very different problems

Once a station is live, the most useful view is not the overall pass rate. It is the pass rate broken out by camera, line or machine, because the shape of that breakdown tells you what kind of problem you have.

Yield breakdown by camera showing five stations between 98.8 and 100 percent and one at 92.4 percent
Same product, same application, one line. Five viewpoints sit between 98.8% and 100%, and one sits at 92.4%. That gap is the finding, not the 94.46% headline above it.

An outlier station like that is almost never a model problem, because every station is running the same model. It is a physical difference: a fixture with more play, a light that has drifted or been knocked, a viewpoint where the part presents differently, or a genuine process difference at that position. The aggregate number would have hidden it completely, and averaging across a fleet is how a single bad station stays invisible for months.

The inverse case is worth naming too. If every station drops together, that is not a fixturing issue, it is either the process or the model. Same data, two very different investigations, and the breakdown is what tells you which one you are in.

A validation sequence you can put in a spec

  1. Agree the defect set. Both parties sign off which parts are defective, including the marginal ones. This is the step that prevents the argument later.
  2. Build the test set from real production, spanning lots and shifts, with ground truth labelled by agreement.
  3. Run the full recipe offline and record escapes and overkill as counts, not as an accuracy percentage.
  4. Open the failures. Every escape and every overkill gets looked at. Patterns in them are the actual output of the exercise.
  5. Run it twice and compare, so repeatability is a measured number rather than an assumption.
  6. Set sensitivity by cost, using the escape and overkill counts against what each one costs you. This is a business decision, not a technical preference.
  7. Keep the test set with the recipe and re-run it as an acceptance step after any change, including a retrain.

Two things about that list are worth emphasising. It contains no accuracy figure anywhere, deliberately, for the reasons covered in our piece on escape versus overkill. And step seven is the one that decays first: a test set that is not re-run after retraining is how a station that passed validation in March quietly stops working in June.

None of this is specific to AI, which is rather the point. It is the same discipline a quality team already applies to every other measurement device, applied to a newer one. Where it fits into the wider station design is covered in our guide to machine vision systems, and if you are validating an anomaly detection station in particular, the marginal parts matter even more than usual, because the trip point is a single sensitivity setting rather than a learned boundary.

Frequently Asked Questions

What is backtesting in machine vision?

Backtesting runs a complete inspection recipe offline over a set of images whose true condition is already known, and compares the recipe verdict against that ground truth. It produces escape and overkill counts before the station gates any real production, which replaces the expensive alternative of discovering the performance in production where the failure under test is a defect reaching a customer. Critically it runs the whole recipe, every model and every rule, because stations usually fail at the seams between correctly behaving models.

How do I build a good test set for a vision inspection?

Include the marginal parts your own inspectors argue about, because that is where the real decision boundary sits. Span the actual variation: different material lots, different shifts, worn tooling as well as fresh. Label ground truth by agreement between more than one person, since disagreement on marginal parts is a specification problem worth surfacing early. Then keep the set and re-run it after every recipe change. If a recipe scores perfectly on the first run, the set is probably too easy rather than the recipe being perfect.

Can you run a gauge R&R study on an AI vision system?

Yes, and it is a fair thing to require. In practice it means passing the same parts through more than once and comparing the verdicts. Divergence points either to genuinely borderline parts sitting on the decision boundary, or to a source of variation in the station itself such as lighting that is not as fixed as assumed, inconsistent part seating, or drifting exposure. Gauge repeatability is already routine for calipers and coordinate measuring machines, and an automated inspection should not be exempt.

Why look at yield per station instead of overall yield?

Because the shape of the breakdown tells you what kind of problem you have. If one station sits well below the others while running the same model, it is almost certainly physical: fixture play, a light that has drifted, a viewpoint where the part presents differently. If every station drops together, it is the process or the model instead. Two completely different investigations, and an aggregate figure hides the distinction, which is how a single bad station stays invisible for months.

How often should a test set be re-run?

After every change to the recipe, including a retrain. This is the step that decays first in practice, and skipping it is how a station that passed validation in one month quietly stops working a few months later. Treating the re-run as an acceptance gate, with the test set version controlled alongside the recipe, is what keeps validation meaningful rather than a one-off exercise at commissioning.

Should a validation specification include an accuracy target?

No. Accuracy is dominated by how many good and bad parts happen to be in the set, so it can look excellent while catching nothing, and it averages together two errors with very different costs. Specify escape count on an agreed defect set, overkill as a percentage of production, demonstrated repeatability across at least two runs, and a retained test set re-run after any change. Those four are measurable, meaningful, and hard to game.

See how Overview AI inspects inspection validation

Send us a photo of your part or defect and a vision engineer will tell you whether Overview can catch it, with most systems deployed on the line in days.

Related Articles