Robustness, label quality, and active data acquisition · Robustness, label quality, and active data acquisition · ROB004 · Training method
Group distributionally robust optimization (Group DRO)
Optimize for the worst expected loss among prespecified groups, rather than weighting groups only by their training prevalence.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- Deep neural network (torch MLP) Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through learn.torch_mlp. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Optimize for the worst expected loss among prespecified groups, rather than weighting groups only by their training prevalence.
Question / hypotheses
Can a model retain useful performance on difficult or rare groups when group proportions change? The guarantee target must specify the groups and allowed shift.
Architecture / computational structure
A shared predictor produces group-specific losses. Adversarial weights on the group simplex increase for high-loss groups; the model minimizes their weighted loss. Regularization and early stopping affect worst-group generalization.
Assumptions
Training group membership is known or reliably defined, groups have usable sample sizes, and the shift family is represented by the selected groups. Group-mixture robustness does not automatically cover arbitrary shifts inside each group.
Formula / computational definition
Parameters and notation
Learned: predictor θ. Optimization state: group weights q. Hyperparameters: model capacity, group-update rate, regularization, early stopping, sampling balance, and optional adjustment terms. Group definitions are substantive design choices, not arbitrary clusters to tune until a desired result appears.
Fitting, fine-tuning, and adaptation
Fine-tune with explicit group-aware validation and retained average-performance checks. Reassess group definitions and sample support on a new domain. Report whether validation group labels influence checkpoint selection; this is additional information compared with ordinary label-only selection.
How to use and calibrate
Compare average, worst-group, and per-group performance with uncertainty and counts. Plot training versus validation group losses. Keep the total optimization budget and preprocessing comparable to an empirical-risk baseline.
Example application
Evaluate a classifier across collection sites and label/site combinations where one site carries a misleading shortcut.
Interpretation / pitfalls
Watch out
Small groups produce noisy worst-group estimates. Zero training loss can coexist with poor worst-group generalization. Improvement over the chosen groups does not establish fairness under every criterion or causal invariance.
Python and R code examples
Scope: One exponentiated group-weight update from supplied losses; no neural fitting. Python: NumPy; R: base R.
Validation: Python executed successfully on the supplied fixture; R reviewed but not executed.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — One exponentiated group-weight update from supplied losses; no neural fitting. Python: NumPy; R: base R. · needs numpy
import numpy as np
q=np.ones(3)/3; risk=np.array([.2,1.2,.6]); eta=.5
logq=np.log(q)+eta*risk; q=np.exp(logq-logq.max()); q/=q.sum()
assert np.isclose(q.sum(),1) and q[1]>q[2]>q[0]
print(q,q@risk)
Component demo, not a trained model — One exponentiated group-weight update from supplied losses; no neural fitting. Python: NumPy; R: base R.
q <- rep(1/3,3); risk <- c(.2,1.2,.6); eta <- .5
logq <- log(q)+eta*risk; q <- exp(logq-max(logq)); q <- q/sum(q)
stopifnot(abs(sum(q)-1)<1e-12,q[2]>q[3],q[3]>q[1])
print(list(weights=q,weighted_risk=sum(q*risk)))
Sources
- Source 1arxiv.org
- Source 2github.com
From the CodeSplash reference, entry ROB004.