Releases: dtroxell19/fairness_training
Releases · dtroxell19/fairness_training
v0.1.0
Added
FairModel— PyTorchnn.Modulewith differentiable fairness layer (cvxpylayers) enforcing hard per-batch constraints during trainingFairModel.wrap()— wrap any existingnn.Modulewith fairness constraints; prediction bounds inferred automatically via dry-run forward passFairTrainer— high-level training loop with early stopping, LR scheduling, checkpoint save/load, and per-epoch fairness gap tracking- Three built-in fairness metrics:
MeanPredictionParity('mean_pred'),MeanResidualFairness('mean_residual'),EqualizedOdds('equalized_odds') FairnessMetricabstract base class for custom affine fairness constraintsvalidate_metric()— pre-training DPP compliance check for custom metricscreate_stratified_dataloaders()— stratified batching that maintains constant group ratios per batch, accepting both numpy arrays and torch tensors- Online primal-dual inference algorithm for small-batch / streaming deployment with sample-weighted average violation guarantee (converges to ≤ ε as T → ∞)
fairness_training.vizmodule:plot_training_history,plot_group_distributions,plot_fairness_tradeoff- Quickstart Colab notebook (
notebooks/quickstart.ipynb) - Full MkDocs documentation site
- CI workflow (pytest on Python 3.10/3.11) and PyPI trusted-publishing workflow
Notes
- Protected attributes must be binary (0/1) columns in the feature matrix X
- Supports up to 2 protected attributes (marginal fairness, enforced independently)
- Training always uses hard per-batch constraints regardless of
b_tau;b_taucontrols the inference regime only (default: 64) weighted_avg_fairness_gap(the theorem-bounded quantity) ≠pooled_fairness_gap; they coincide only when group ratios are constant across batches