refactor(discriminatory-behavior): migrate to new defense architecture#79
Open
asim29 wants to merge 1 commit intopr/4.5-unauth-model-ownershipfrom
Open
refactor(discriminatory-behavior): migrate to new defense architecture#79asim29 wants to merge 1 commit intopr/4.5-unauth-model-ownershipfrom
asim29 wants to merge 1 commit intopr/4.5-unauth-model-ownershipfrom
Conversation
…hitecture AdversarialDebiasing subclasses DiscriminatoryBehaviorDefense(ABC). Dead imports (numpy, sklearn.metrics) removed. adversary_auc() extracted from the defense into DiscriminatoryBehavior metrics class as a static method with best-threshold AUC logic. p_rule() now returns 0.0 on divide-by-zero. Example updated to use load_or_train.
4 tasks
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Sixth in the
refactor/risk-modulesstack. Stacked on #78 (unauth model ownership vertical).Changes
amulet/discriminatory_behavior/defenses/adversarial_debiasing.pyAdversarialDebiasingsubclassesDiscriminatoryBehaviorDefense(ABC)and delegatesmodel,criterion,optimizer,train_loader,test_loader,devicetosuper().__init__().numpy,sklearn.metrics) removed — no longer used afteradversary_aucwas moved to the metrics class.amulet/discriminatory_behavior/metrics/discriminatory_behavior.pyadversary_auc()extracted from the defense intoDiscriminatoryBehavioras a@staticmethod, keeping attacks/defenses free of metric logic per API contract.p_rule()now returns0.0on divide-by-zero instead of propagatingnan.examples/defense_pipelines/run_adversarial_debiasing.pyload_or_traininstead of manual save/load blocks.tests/integration/test_discriminatory_behavior.py(new)AdversarialDebiasing.train_fair()verifying model weights change anddiscmodelattribute is set.tests/unit/test_metrics_discriminatory.py(new)p_rule,demographic_parity,true_positive_parity,false_positive_parity, andaccuracycovering edge cases including divide-by-zero.Test plan
uv run pytest tests/integration/test_discriminatory_behavior.py -v -m integrationuv run pytest tests/unit/test_metrics_discriminatory.py -vuv run pre-commit run --all-files