Menu

1 / 4

96.7% accuracy and it never flags a defect: class imbalance in visual inspection

DEV Community: computervision·Sathvik Dembale Krishnappagowda·14 days ago
#S5OVydAX
Long article (2520 words) — no AI summary yet.
Reading 0:00
15s threshold

In short

When 1 part in 30 is defective, a model that calls every part good scores 96.7% accuracy and catches no defect at all.

On synthetic washer images, a trained model scored lower , 96.0%, yet caught 4 of 10 corroded washers. Accuracy ranks the useless model first.

Count defects caught and good parts flagged instead, and set the decision threshold from what a missed defect costs. The same model then caught 6 to 9 of 10, while flagging 27 to 42 of 290 good washers instead of 6.

The problem

A classifier sorts each image into a class, here good or corroded . The usual score is accuracy : the share of images it sorts correctly.

In inspection, defects are rare. If 1 part in 30 is defective, 29 of every 30 images are good ones. Accuracy then mostly measures how well the model recognizes good parts. A model can score high while it lets almost every defect through.

Two numbers tell you what you need to know:

Defects caught: of all defective parts, how many the model flags.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.