Online Defect Classification: Economic Calibration of the Rejection Threshold
Image generated by the Inferama Editorial Team
01

The Economic Cost of Binary Classification in Production

Defect detection on a production line is not a problem of average accuracy, but of expected cost per error. A false positive rejects a good part, generating rework, material loss, and machine downtime. A false negative lets a defective part pass, causing returns, warranty claims, and reputational damage. The critical decision boundary is the model's confidence threshold: the cutoff point that separates 'defect' from 'acceptable'.

The viability of computer vision does not depend on maximizing global accuracy, but on minimizing the total expected cost given the ratio between the cost of a false positive and that of a false negative. On a high-speed line, a system that rejects 5% of good parts may be economically unviable if rework is expensive, while a system that lets 1% of defects pass may be unacceptable if the product is safety-critical.

Costs associated with each error type in quality control

Error TypeImmediate ConsequenceTypical Cost (Relative)Long-term Impact
False PositiveRejection of good partLow-Medium (rework, material)Low (if corrected quickly)
False NegativeDefective part to customerHigh (warranty, return)High (reputation, safety)
02

Building a Representative Validation Set

Accuracy reported in the lab rarely translates to the plant. Real variability includes changes in lighting, camera angles, material types, dirt, and tool wear. A validation set that does not capture this variability produces an overestimation of performance and a poorly calibrated threshold.

To build a valid set, images must be captured under all operating conditions: different shifts, different material batches, and known and unknown defects. The proportion of defects in the set must reflect the actual line rate, not an artificially balanced proportion. If the line produces a 2% defect rate, the validation set must contain approximately that 2% of defective images for escape metrics to be realistic.

03

Calibrating the Confidence Threshold: From Cutoff to Minimum Cost

The confidence threshold is the parameter that adjusts the balance between false positives and false negatives. A high threshold reduces false negatives but increases false positives. A low threshold does the opposite. Correct calibration does not seek the point of maximum accuracy, but the minimum of the total expected cost.

The calibration process requires knowing the relative cost of each error. If a false negative costs 10 times more than a false positive, the threshold must shift toward more aggressive detection, accepting more rejections of good parts to prevent defects from reaching the customer. This calibration must be performed on the representative validation set, not on the training set.

04

Data Drift and Recalibration Protocols

The distribution of defects on a production line is not static. Changes in material, tool wear, temperature variations, or process adjustments generate distribution drift. A model calibrated today may have degraded performance in weeks or months.

Recalibration protocols must include continuous monitoring of false positive and negative metrics on the line. If the false positive rate increases sustainably, it may indicate that the threshold is misadjusted or that the distribution of good parts has changed. If the false negative rate increases, it may indicate new types of defects not seen in training. Recalibration may involve adjusting the threshold, retraining the model with new images, or both.

Monitoring and Recalibration Protocol

  1. 01Record the daily false positive and false negative rates on the line.
  2. 02Compare current rates with the baseline established during initial calibration.
  3. 03If the deviation exceeds 20% for 3 consecutive days, initiate a review.
  4. 04Analyze images of recent errors to identify drift patterns.
  5. 05Adjust the threshold or retrain the model with new images.
  6. 06Validate the new threshold on a recent test set before deploying it.
05

When Manual Inspection or Simple Rules Remain More Efficient

Computer vision is not a universal solution. For well-defined defects, with low variability and moderate error cost, a rule-based system or manual inspection may be more efficient. Rule-based systems are cheaper, more interpretable, and easier to maintain, but they do not generalize to unseen defects.

Manual inspection remains competitive when the defect rate is very low, the cost of an error is low, and variability is high. In these cases, the cost of implementing and maintaining a computer vision system may exceed the savings in errors. The decision must be based on a cost-benefit analysis that includes implementation cost, maintenance cost, error cost, and the value of inspection time.

Decision Criteria: Computer Vision vs. Manual Inspection vs. Rules

CriterionComputer VisionManual InspectionRule-Based System
Defect VariabilityHighHighLow
Implementation CostHighLowMedium
MaintenanceHigh (recalibration)LowLow
ScalabilityHighLowMedium
InterpretabilityLowHighHigh
06

Keep exploring

Sources consulted

03

Corrections and transparency

If you spot incorrect or outdated information, send us a correction with the page and source we should review.

Submit a correction