Towards Robust Classification Model by Counterfactual and Invariant Data Generation

Chun-Hao Chang, George-Alexandru Adam, Anna Goldenberg

Introduction: The Shortcut Problem

Standard machine learning models are notorious for taking "shortcuts." If a dataset consistently depicts cows on green pastures and camels on desert sands, a model might learn that "green pixels = cow," failing completely when presented with a cow on a beach. These are spurious correlations—features that correlate with the label in the training set but are not causally linked to the object itself.

While previous research has attempted to mitigate this by regularizing the model (directing its attention), these methods often struggle with the complexity of high-dimensional image data. This paper, "Towards Robust Classification Model by Counterfactual and Invariant Data Generation," addresses the problem at its source: the training data.

Proposed Methodology: Counterfactual and Factual Generation

The authors introduce a framework that utilizes human-annotated "causal regions" (such as bounding boxes) to generate two types of synthetic data:

  1. Counterfactual (CF) Generation: This process asks, "What if the object was removed?" By removing causal pixels and "infilling" the resulting hole (using techniques like random noise, shuffling, or Contextual Attention GANs), the model is presented with a background that lacks the target object. These images are assigned a "not-y" label, forcing the model to learn that the background alone is insufficient for classification.
  2. Factual (F) Generation: This process asks, "What if the object appeared in a different environment?" Here, the causal object is preserved while the background is perturbed or swapped entirely (e.g., using "Mixed-Rand"). These images retain the original label, teaching the model to remain invariant to environmental shifts.
Visualizing Counterfactual (CF) and Factual (F) data generation techniques across different infilling and perturbation methods.

The study highlights that CAGAN provides the most realistic counterfactuals, while Mixed-Rand is particularly effective for factual generation by introducing diverse background contexts.

Evaluation Benchmarks

The methodology was tested on three benchmarks specifically designed to evaluate background robustness:

  • IN-9 (ImageNet-9): A subset of ImageNet grouped into 9 classes to disentangle foreground and background features.
  • Waterbirds: A classic benchmark where waterbirds typically appear on water and landbirds on land. The test set "flips" these associations to expose shortcut learning.
  • CCT (Caltech Camera Trap): A real-world dataset of animals captured by motion-sensor cameras, testing "trans-location" robustness—recognizing species in entirely new physical environments.

Key Insights

  • Data Augmentation vs. Model Regularization: The authors found that generating new data is often more effective than saliency regularization (penalizing the model for looking at the wrong pixels). Data provides a more direct signal for the model to ignore spurious features.
  • The "Not-Y" Label: Using a negative log-likelihood loss to label counterfactual images as "not the original class" is a clever mechanism to break background-label associations without requiring a dedicated "background" class.
  • Methodological Synergy: The most significant gains were observed when combining Counterfactuals, Factuals, and Saliency Regularization, suggesting these approaches address shortcut learning in complementary ways.

Results and Performance

The combined approach yielded substantial improvements across all benchmarks:

  • Waterbirds: Achieved a 19% relative improvement on the "Flip" test set compared to the baseline.
  • IN-9: Outperformed the baseline by nearly 8% accuracy on the "Mixed-Next" challenge (backgrounds from different classes).
  • CCT: Improved the Area Under the Curve (AUC) by 5.4% in the most difficult trans-location settings.
Performance curves demonstrating the cumulative benefit of combining Counterfactual (CF), Factual (F), and Saliency (Sal) methods.

Limitations and Future Outlook

Despite its success, the method relies on human-provided bounding boxes, which are expensive to scale. Future work may involve using pre-trained segmentation models or few-shot learning to automate rationale generation. Additionally, the quality of the "infilling" in counterfactual generation remains a critical factor; if the process is too noisy, the model might learn to associate artifacts with the "not-y" class rather than the absence of the object.

Summary updated

BibTeX
@inproceedings{chang2021towards,
  author = {Chun-Hao Chang and George-Alexandru Adam and Anna Goldenberg},
  title = {{Towards Robust Classification Model by Counterfactual and Invariant Data Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  doi = {10.1109/cvpr46437.2021.01496},
}
Figure