Skip to content

refactor(attr-inference+data-recon): migrate to new attack architecture#80

Open
asim29 wants to merge 1 commit intopr/4.6-discriminatory-behaviorfrom
pr/4.7-attribute-data
Open

refactor(attr-inference+data-recon): migrate to new attack architecture#80
asim29 wants to merge 1 commit intopr/4.6-discriminatory-behaviorfrom
pr/4.7-attribute-data

Conversation

@asim29
Copy link
Copy Markdown
Collaborator

@asim29 asim29 commented Apr 21, 2026

Context

Seventh in the refactor/risk-modules stack. Stacked on #79 (discriminatory behavior). Final risk-vertical PR.

Changes

amulet/attribute_inference/attacks/duddu_cikm_2022.py

  • DudduCIKM2022 subclasses AttributeInferenceAttack(ABC) and delegates target_model, x_train_adv, x_test, z_train_adv, device to super().__init__().
  • attack() return type narrowed to dict[int, dict[str, np.ndarray]].

amulet/attribute_inference/metrics/attack_accuracy.py

  • Docstring converted to Google style; :class: RST markup removed.

amulet/data_reconstruction/attacks/fredrikson_ccs_2015.py

  • FredriksonCCS2015 subclasses DataReconstructionAttack(ABC) and delegates target_model, input_size, output_size, device to super().__init__().

amulet/data_reconstruction/metrics/similarity_evaluation.py

  • Module-level __figure_mse (mangled name, invisible outside module) replaced with a module-private _figure_mse helper. Docstring converted to Google style.

examples/attack_pipelines/run_attribute_inference.py / run_data_recon.py

  • Updated to use load_or_train instead of manual save/load blocks.

tests/integration/test_other_risks.py (new)

  • Smoke tests for DudduCIKM2022.attack(), FredriksonCCS2015.attack(), and SuriEvans2022.attack().

tests/integration/test_celeba_datasets.py, test_lfw_datasets.py, test_utkface_datasets.py (new)

  • Integration tests for the CelebA, LFW, and UTKFace dataset loaders (marked @pytest.mark.integration; require network/disk access).

tests/unit/test_metrics_attribute.py (new)

  • Unit tests for evaluate_attribute_inference covering perfect-prediction identity and output shape.

Test plan

  • uv run pytest tests/integration/test_other_risks.py -v -m integration
  • uv run pytest tests/unit/test_metrics_attribute.py -v
  • uv run pre-commit run --all-files
  • CI passes on this branch

…ls to new architecture

DudduCIKM2022 subclasses AttributeInferenceAttack(ABC); FredriksonCCS2015
subclasses DataReconstructionAttack(ABC). attack_accuracy: docstring
converted to Google style. similarity_evaluation: module-level __figure_mse
replaced with a module-private helper. Examples updated to use load_or_train.
Dataset integration tests added for CelebA, LFW, and UTKFace loaders.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant