What does a false alarm cost in a vision inspection system?
A false alarm costs whatever happens to a good part after the system rejects it: the time to re-inspect it, the material lost if it is scrapped or reworked, the minutes the line stands still, and the operator attention it uses up. None of these show up in a model's accuracy figure, yet together they decide whether an inspection system is worth running.
The missed defect, the other error, has its own price, and it depends on where the defect is eventually found. Caught at the next station, it may mean a few minutes of rework. Caught at final inspection, it costs everything added to the part since. Found by the customer, it brings a return, transport, complaint handling and possibly a warranty claim. For safety-critical defects, the missed defect is not a cost to be traded at all but a limit that must not be crossed.
Most teams price only the error they can see. False alarms are visible every shift, because someone has to walk to the reject bin. Missed defects are invisible until they come back. A system tuned only to silence the reject bin is quietly tuned to ship more defects.
Why do false alarms dominate when defects are rare?
Because the number of good parts is so much larger than the number of defective ones, even a small false-alarm rate produces as many alarms as the real defects do. This is a base-rate effect, and it surprises almost every team the first time they see production numbers.
Hypothetical example: a line makes 1,000 parts per shift and 2% are defective, so 20 parts. A model catches 95% of defects (19 parts) and wrongly flags 2% of good parts (about 20 of 980). Half of all alarms are false. If the process improves and the defect rate falls to 0.5%, the same model catches about 5 defects and still raises about 20 false alarms, so four alarms in five are false. The model did not get worse; the line got better.
This is why Google's machine learning course on classification thresholds warns that 0.5 may seem like an intuitive threshold but is not a good choice when one kind of wrong classification costs more than the other; the same course treats datasets where one class is far rarer than the other as a separate, imbalanced case. Report counts per 1,000 parts, split by error type, rather than a single percentage. A 98% accuracy figure can describe a model that misses every defect on a line where 2% of parts are defective.
How do you put a price on each error type?
Build a cost table with the people who pay each cost: operations, quality and finance. Write each figure as a range with its source, not as a single number someone guessed in a meeting.
| Error | Cost item | How to measure it |
|---|---|---|
| False reject | Re-inspection | Minutes per rejected part × labour cost, from a timed sample |
| False reject | Scrap or rework of a good part | Share of rejects scrapped without re-inspection × part cost |
| False reject | Line stop | Stop minutes per alarm × cost of a line minute, if the system stops the line |
| Missed defect | Caught downstream in the plant | Rework or scrap cost at the station that finds it |
| Missed defect | Reaches the customer | Return, transport, complaint handling and warranty cost per case |
| Missed defect | Safety-critical | Not priced; set a maximum number of escapes instead |
Charles Elkan's paper The Foundations of Cost-Sensitive Learning (IJCAI 2001) adds two useful rules. First, costs do not have to be money; they can be time or severity, as long as every entry in the table is measured from the same baseline. A table that counts the lost profit of one decision against the lost principal of another is, in his words, economically incoherent. Second, multiplying every cost by the same constant or adding the same constant to all of them does not change which decision is optimal. In practice that means you do not need exact figures; you need the right ratio between them.
How do you turn costs into a decision threshold?
If the model's scores are calibrated probabilities and correct decisions cost nothing, the cost-minimising rule is simple: reject a part when its defect probability is at least the false-reject cost divided by the sum of the false-reject cost and the missed-defect cost. This follows from equation 2 in Elkan's paper.
Hypothetical example: a false reject costs 8 units (re-inspection time) and a missed defect costs 120 units (rework after assembly). The threshold is 8 ÷ (8 + 120) ≈ 0.06. The system should reject a part when it estimates a defect probability of about 6% or more, far below the default of 0.5.
Two conditions limit this shortcut. The scores of many vision models are not calibrated probabilities, and the cost ratio is itself uncertain. So in practice the threshold is tuned on held-out images against the cost function. scikit-learn's guide to tuning the decision threshold describes doing this with cross-validation and warns that the same data should never be used for training the classifier and for tuning the threshold, because of the risk of overfitting. Its cost-sensitive learning example applies the same idea to a credit dataset in which one error is counted as five times as costly as the other, and the tuned threshold ends up far from 0.5.
Threshold cost calculator
The calculator below is a specification you can build in a spreadsheet or a notebook. It compares candidate thresholds on held-out production images and makes the cost assumptions explicit.
- Inputs per product and defect class: parts per shift, defect prevalence, and for each candidate threshold the number of false rejects and missed defects per 1,000 parts from a held-out set.
- Cost inputs: cost per false reject and per missed defect, each as low, expected and high values, built from the table above.
- Calculation: error cost per 1,000 parts = false rejects × false-reject cost + missed defects × missed-defect cost.
- Outputs: cost per threshold at each cost level, the missed-defect cost at which the preferred threshold changes, the review load per hour, and a pass or fail against any hard limit on safety-critical escapes.
Hypothetical worked example for a batch of 1,000 parts with 20 true defects, a false reject at 8 units and a missed defect at 120 units:
| Threshold | False rejects | Missed defects | Error cost |
|---|---|---|---|
| A (strict) | 25 | 2 | 25 × 8 + 2 × 120 = 440 |
| B (loose) | 8 | 5 | 8 × 8 + 5 × 120 = 664 |
| C (very strict) | 60 | 1 | 60 × 8 + 1 × 120 = 600 |
Threshold A is cheapest even though it raises more than three times as many false alarms as B. Now run the sensitivity check. If a missed defect costs 40 units instead of 120, A costs 280 and B costs 264, so B wins. A and B cost the same when a missed defect costs about 45 units (25 × 8 + 2c = 8 × 8 + 5c). If your honest estimate of the missed-defect cost spans that point, the threshold decision depends on a number nobody has measured yet. Record the decision as uncertain and collect better rework or return data before automating the gate.
Where does human review fit in?
A review band sends the parts the model is least sure about to a person: below a lower threshold the part passes, above an upper threshold it is rejected, and in between someone looks. It reduces both errors, but only if reviewers have the time to look properly.
Size the band from capacity, not from model scores. Hypothetical example: a line runs 600 parts per hour and the band catches 3% of them, so 18 reviews per hour. At 40 seconds each, that is 12 minutes of every operator hour. If the band widens to 10%, review takes 40 minutes of every hour, and the job has changed.
Alarm guidance from the process industries is a useful reference for what happens when people are asked to confirm too much. The UK Health and Safety Executive's information sheet on better alarm handling recalls that in the last 11 minutes before the 1994 Milford Haven refinery explosion, two operators had to recognise, acknowledge and act on 275 alarms. It cites a long-term target of no more than one alarm every ten minutes in normal operation, and lists signs of nuisance alarms: many alarms acknowledged in quick succession, or audible alarms routinely switched off. The same signs apply to a reject screen. If reviewers confirm parts in under a second, they are no longer reviewing.
Should every defect type share one threshold?
No. A safety-relevant crack and a cosmetic mark have different missed-defect costs, so they need different thresholds, and often different rules. Treat safety-critical classes as a hard limit (a maximum number of escapes per 1,000 parts on the test set) and optimise cost only for the remaining classes. Set thresholds per product, too, when products differ in value or in how far a defect can travel before it is caught.
If several cameras inspect the same part, remember that their false alarms add up. A part is rejected when any view flags it, so the part-level false-alarm rate is higher than any single camera's.
How do you check that the threshold keeps paying off?
Compare the predicted cost with the cost that actually occurs, shift by shift, and recalculate whenever the inputs change. Start in shadow mode: the system records its decisions without acting, and you compare them with the existing inspection.
- Measure false alarms directly: alarms per 1,000 parts and the share confirmed as real defects.
- Measure misses deliberately: missed defects are invisible unless you audit a sample of passed parts every shift and record what downstream stations and customer returns find.
- Track the review band: reviews per hour and median review time.
- Keep a rollback value: store the previous threshold and name the person who approves a change.
- Recalculate on change: new product mix, new lighting, a new camera or a change in rework or warranty cost.
Common mistakes
- Keeping the default threshold of 0.5 or choosing the threshold by accuracy.
- Pricing only the false alarm, because it is the error people can see.
- Tuning the threshold on the same images used to train the model.
- Using one threshold for every defect class and every product.
- Adding a review band without measuring review capacity.
- Never auditing passed parts, so missed defects are never counted.
Camera placement and review workflows on the line are covered in our article on computer vision for quality control. Setting thresholds from what a missed defect and a false alarm cost the plant is part of the scope described on our visual quality inspection service page.