Practice in Lab: Project: audit ERM and Group DRO under a spurious correlation →
Project: audit ERM and Group DRO under a spurious correlation
A majority-aligned shortcut can make average accuracy look reassuring while minority groups fail. This experiment creates that failure mode explicitly with generated causal and spurious features, then compares two actual optimizer objectives from the same initialization. Validation selects checkpoints before test labels are observed. Reports retain per-group results, row identities and a reloadable artifact rather than declaring that a robust objective must win every seed. The data are a controlled synthetic stress test, not real-world robustness evidence.
Prepare offline
Choose Download entire course or Download entire category first. After completion, code and checks run locally on CPU. The independent example needs no account, remote service or API key.
import torch
labels = torch.tensor([0, 0, 1, 1])
shortcut = torch.tensor([0, 1, 0, 1])
print((labels == shortcut).float().mean())Review the evidence
Run several seeds and compare validation selection, average test accuracy and the worst group. Explain how group definition, regularization and a shift outside the declared groups can change the conclusion.
Your task
Implement the complete experiment using the supplied make_data/tensors/classification/train_model helpers. Generate the declared local synthetic four-group dataset, train ERM and Group DRO from identical initialization, choose each checkpoint only by validation worst-group accuracy then validation loss, and evaluate the untouched test set once. Return the reference schema with both models, disjoint row IDs, train/validation fit hash, source hash, measured history and a real serialized artifact. The artifact includes both model states and initialization for independent audit. Reload into a fresh model and verify predictions. Test-label overrides must affect only evaluation, never selection or weights. The reference CLI writes model/report files in the current project. Report empirical sample group masses for ERM and the adversary probabilities belonging to the selected DRO checkpoint; serialize those probabilities and selected step with each model.
The explanation opens here once every check passes.