PythiloLesson 7 of 8 · progress kept in this browser

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.

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.

This lesson uses torch, which Python in this browser does not include. Read it here, and run and check it in the Pythilo app on iPhone or iPad.