0
0
TensorFlowml~8 mins

Data augmentation for images in TensorFlow - Model Metrics & Evaluation

Choose your learning style9 modes available
Metrics & Evaluation - Data augmentation for images
Which metric matters for Data Augmentation and WHY

When using data augmentation for images, the main goal is to improve the model's ability to generalize. This means the model should perform well on new, unseen images. The key metrics to watch are validation accuracy and validation loss. These show how well the model works on data it has not seen during training.

Data augmentation helps by creating new, varied images from the original ones. This reduces overfitting, where the model only memorizes training images. So, a good sign of effective augmentation is when validation accuracy improves or stays stable while training accuracy grows.

Confusion Matrix Example

For image classification, a confusion matrix helps us see how well the model predicts each class. Here is an example for a 3-class problem:

      | Predicted: Cat | Predicted: Dog | Predicted: Bird |
      |----------------|----------------|-----------------|
      | True Cat: 45   | 3              | 2               |
      | True Dog: 4    | 40             | 6               |
      | True Bird: 1   | 5              | 44              |
    

This matrix shows the model's correct and wrong guesses. Data augmentation aims to improve these numbers by making the model more robust.

Precision vs Recall Tradeoff with Data Augmentation

In image tasks, precision and recall matter depending on the goal:

  • Precision means when the model says an image is a certain class, it is usually right.
  • Recall means the model finds most images of that class.

Data augmentation can help balance these by exposing the model to varied images. For example, in medical image diagnosis, high recall is critical to catch all cases. Augmentation helps the model not miss rare patterns.

Good vs Bad Metric Values for Data Augmentation

Good:

  • Validation accuracy close to or improving over training accuracy.
  • Validation loss decreasing or stable, not increasing.
  • Balanced precision and recall for important classes.

Bad:

  • Validation accuracy much lower than training accuracy (overfitting).
  • Validation loss increasing while training loss decreases.
  • Very low recall on important classes, meaning many missed detections.
Common Pitfalls in Metrics with Data Augmentation
  • Data Leakage: Augmented images leaking into validation set can falsely boost validation accuracy.
  • Overfitting: If augmentation is too weak, model still memorizes training images.
  • Underfitting: Too strong augmentation can make images unrealistic, hurting learning.
  • Ignoring Class Imbalance: Metrics like accuracy can be misleading if some classes dominate.
Self Check

Your image classifier trained with data augmentation has 98% training accuracy but only 70% validation accuracy. What does this mean?

Answer: This suggests overfitting. The model learned training images well but does not generalize to new images. Data augmentation might be too weak or not diverse enough. You should try stronger or different augmentation techniques and check for data leakage.

Key Result
Validation accuracy and loss are key to check if data augmentation helps the model generalize better.