PART VI · MODEL TRAINING AND RELIABILITY

How Do You Choose a Decision Threshold? The Cost of False Alarms and Missed Defects

False alarms, missed defects and prevalence are combined in an expected-cost calculation for acceptance decisions. A single threshold is compared with a two-threshold accept–review–reject policy. Hourly throughput examples translate review rates into operator workload, showing how capacity constrains threshold choice alongside quality targets. Recording and approving threshold changes completes the decision protocol.

Article sectionsA threshold is more than a model parameterA false alarm is not the same as a false acceptanceWhy does prevalence change the whole picture?Calculating expected costInterpreting threshold curves correctlyTwo thresholds instead of oneThreshold changes in productionWriting the decision protocolField scenarioComparing two threshold candidates on the same cost basisFrequently asked questionsReferences

A threshold is more than a model parameter

When a classifier outputs a defect probability or defect score, that score can be converted into a binary decision using a threshold such as 0.5. However, 0.5 is not always the best threshold. The model score may be uncalibrated, the defect rate may be low, or the cost of missing a critical defect may be very high. Threshold selection is the mathematical expression of operational decisions.

Repeatedly optimizing the decision threshold on the test set biases the test evaluation. The threshold should be selected on the validation set, verified on a separate test set, and monitored during the transition to production.

Three decision regions in a two-threshold policyScore < t1Automatic acceptancet1 ≤ score < t2Human reviewScore ≥ t2Automatic rejection
Figure 1. Example policy where higher scores indicate stronger defect evidence. Validation data and review capacity determine t1 and t2; there is no universal threshold.

A false alarm is not the same as a false acceptance

If defective products are the positive class, FP means incorrectly rejecting a non-defective product, and FN means missing a defective product. However, plant terminology may use 'false accept' and 'false reject' from the product's perspective. Mapping these names to operational events in the report prevents confusion.

A false rejection can incur the cost of scrapping a non-defective product, reinspection, or a line stoppage. A missed defect can lead to costs associated with shipping defective products to customers, warranties, recalls, or safety. These costs are usually not equal.

Why does prevalence change the whole picture?

Suppose that among 10,000 products, the defect rate is 1%, recall is 99%, and FPR is 2%. While 99 of the 100 defects are detected, approximately 198 of the 9,900 non-defective products trigger false alarms. Thus, only 99 of the 297 positive flags are actual defects: precision is approximately 33.3%. Despite the impressive recall, the inspection queue contains one actual defect for every two non-defective products.

This result demonstrates the operational importance of low defect rates. If the defect rate changes with a new shift or supplier, the precision of the same model may also change. Rather than merely adjusting the threshold, data quality and the prevalence of the target class must be monitored.

Calculating expected cost

A simple expected-cost approach is: number of false rejections × cost per false rejection + number of missed defects × cost per missed defect. For example, if each of 200 false alarms costs 20 TL and each of 2 missed defects costs 2,000 TL, the total is 8,000 TL. These numbers are illustrative only; actual costs may also include additional labor, line stoppages, and shipping impacts.

When risk involves tail events or safety consequences, the monetary expected value alone is insufficient. It may be more appropriate to define hard upper limits on missed critical defects.

Interactive simulator: threshold and expected error cost

Calculations use 1000 illustrative scores; these are not outputs from a real model. Adjust the threshold and costs.

Detected defects—
Missed defects—
False rejections—
Precision—
Illustrative error cost—

To illustrate the distribution, scores were generated deterministically so that non-defective products mostly have low scores and defective products have high scores. Threshold selection must be performed on the validation set.

Interpreting threshold curves correctly

As the threshold increases, the model generally flags fewer products as defective: false alarms may decrease, while missed defects may increase. However, this directional relationship applies to the classification score; anomaly scores or reverse-coded scores may be defined differently. Threshold curves must always be calculated from labeled validation predictions.

Plotting recall, FPR, precision, and estimated error cost per product together across all thresholds makes the cost of the decision visible. Review capacity and quality requirements must both be specified as constraints.

Two thresholds instead of one

Rather than making automatic decisions in the uncertain region, two thresholds can be used: low scores lead to automatic acceptance, high scores to automatic rejection, and the region between them to manual review. This design is closely related to selective classification and abstention. Reducing errors in automatic decisions may increase operator workload.

Thresholds should be selected not solely on theoretical grounds, but based on review capacity per shift, error type, the relative importance of different classes, and operator intervention time.

Threshold changes in production

When the defect distribution, camera calibration, or production batch changes, a threshold selected during validation may become unsuitable over time. Automatically changing the threshold can, in turn, create unexpected quality risks. Monitoring, alerts, and controlled change management are important.

Every threshold change must be recorded with the data version, rationale, expected effects, and rollback plan. Allowing operators to review past decisions provides auditability.

Writing the decision protocol

A good decision protocol explains which products receive automatic decisions, how borderline samples are routed, the tolerance for missed critical defects, and who owns the threshold. Without change acceptance testing, a controlled live trial, and clearly assigned responsibilities, a model score alone cannot serve as a production standard.

The best threshold is not the one that delivers the highest possible F1, but the one that satisfies predefined quality and capacity constraints while carrying quantifiable risk.

Practical field scenario: the cost of a low defect rate

Because defects are rare on a production line, false rejections can be numerous despite good recall. If the reinspection station can process only 300 images per hour, threshold selection is constrained by capacity as well as quality requirements. A two-threshold system can reduce the risk of automatic decisions; however, widening the intermediate region may cause a queue to build up.

Considerations for threshold optimization

The meaning of 'optimal' in production must be defined in advance. Does it mean the lowest expected cost, the fewest false rejections above a specified recall floor, or the highest automation rate under limited review capacity? A different objective may lead to a different threshold. Optimization is therefore a matter of quantifying business requirements before selecting a validation metric.

A calibrated prediction score and an uncalibrated anomaly score must not be interpreted in the same way. A high anomaly score may lead to a positive decision, but it is incorrect to assume that the score directly represents a probability. Before making decisions, score distributions, defect prevalence, and class-specific error rates must be measured using independent samples.

The decision boundary and the production queue

Example: on a line processing 5,000 products per hour, the model routes 8% of products to the uncertain region. This means 400 human reviews per hour. If reviewing an image takes an average of 12 seconds, the theoretical workload is 1.33 operator-hours/h. Accounting for workload fluctuations, breaks, and reinspection, at least two simultaneous reviewers may be needed. Changing the quality threshold therefore also changes staffing and cycle-time decisions.

Separate thresholds for product families

For some product types, defects have high contrast and are easy to find; for others, specular reflections generate false alarms. Product-family-specific thresholds can be considered instead of a shared threshold. However, a custom threshold may cause overfitting in groups with insufficient validation samples. Each additional threshold increases the monitoring and change-management burden.

Points to check in the field

  • Data source: Clearly define the product, batch, camera, shift, and sampling method.
  • Decision unit: Do not conflate measurements at the image, defect, product, and production-line levels.
  • Success criteria: Document the metric target together with latency, throughput, cost, and tolerance for critical errors.
  • Alternatives: Evaluate whether simpler methods and improvements to the physical setup can meet the same need.
  • Validation: Use a test protocol that is independent of the training data and representative of production conditions.
  • Change log: When the model, threshold, optical settings, or label definition changes, archive the rationale for the decision and its consequences.

Comparing two threshold candidates on the same cost basis

In an illustrative batch of 10,000 parts with 100 defects, let threshold A yield 90% recall and a 1% false-positive rate on good parts: 90 TP, 10 FN and 99 FP. A lower threshold B yields 95% recall and a 3% false-positive rate: 95 TP, 5 FN and 297 FP. These are assumed operating points for the same population, not a measured model curve.

If a missed defect costs 1,000 units and a false rejection costs 5, A costs 10×1,000+99×5=10,495 units; B costs 5×1,000+297×5=6,485. B has lower error cost under these assumptions, but raises alerts from 189 to 392. This calculation includes only FN and FP costs. Rework, review and queue delays require separate terms; uncertain costs can be explored with sensitivity ranges.

Choose the threshold using independent validation or suitable cross-validation, not minimum training-set cost. For two-threshold review policies, measure defect prevalence and review time within the referred region. Freeze the policy before final testing and version it. Lowering a production threshold changes acceptance behaviour even when model weights stay unchanged, so it needs an owner and rollback conditions.

Frequently asked questions

Is 0.5 the best threshold?

No. Error costs, class prevalence, and score calibration must be evaluated.

Can the threshold be selected during model testing?

Repeatedly adjusting the threshold based on test data compromises the independence of the test; use the validation set instead.

References and further reading

The primary sources below explain the methods and evaluation protocols. Numerical scenarios in this article are educational examples, not measured results from a facility or model.

  1. scikit-learn: selecting decision thresholds with validation data
  2. scikit-learn: confusion matrices and cost-aware evaluation