For image classification using CNNs, accuracy is the most common metric because it shows how many images are correctly labeled out of all images. However, when classes are imbalanced, precision and recall become important to understand if the model is good at finding specific classes without too many mistakes.
Why CNNs dominate image classification in Computer Vision - Why Metrics Matter
| Predicted Cat | Predicted Dog |
|--------------|---------------|
| True Cat: 90 | False Dog: 10 |
| False Cat: 5 | True Dog: 95 |
Total samples = 200
Precision (Cat) = TP / (TP + FP) = 90 / (90 + 5) = 0.947
Recall (Cat) = TP / (TP + FN) = 90 / (90 + 10) = 0.9
Accuracy = (TP + TN) / Total = (90 + 95) / 200 = 0.925
In image classification, sometimes you want high precision to avoid false alarms. For example, if a model detects rare animals, you want to be sure when it says "this is a rare animal" it is correct (high precision).
Other times, you want high recall to catch all instances. For example, in medical image classification, you want to find all tumors even if some false alarms happen (high recall).
CNNs help balance this tradeoff by learning detailed features that improve both precision and recall compared to older methods.
Good: Accuracy above 90%, precision and recall both above 85% means the CNN is correctly classifying most images and not missing many.
Bad: Accuracy around 50-60% or precision very low (below 50%) means the model guesses poorly or confuses classes a lot.
- Accuracy paradox: High accuracy can be misleading if one class dominates the dataset.
- Data leakage: If test images are too similar to training images, metrics look better than reality.
- Overfitting: Very high training accuracy but low test accuracy means the CNN memorized training images but can't generalize.
Your CNN model has 98% accuracy but only 12% recall on a rare class like cancer in images. Is it good for production? Why or why not?
Answer: No, it is not good. The model misses 88% of cancer cases (low recall), which is dangerous. High accuracy is misleading because cancer cases are rare. You need to improve recall to catch more cancer cases.