Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2024
1 parent 7ac6ca7 commit affb7c7
Show file tree
Hide file tree
Showing 16 changed files with 981 additions and 971 deletions.
1 change: 1 addition & 0 deletions aisdc/attacks/likelihood_attack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Likelihood testing scenario from https://arxiv.org/pdf/2112.03570.pdf."""

# pylint: disable = invalid-name
# pylint: disable = too-many-branches

Expand Down
1 change: 1 addition & 0 deletions aisdc/attacks/multiple_attacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
and attribute inference attack using a single configuration file
with multiple attack configuration.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions aisdc/attacks/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Code for automatic report generation."""

import abc
import json
import os
Expand Down
30 changes: 15 additions & 15 deletions aisdc/attacks/worst_case_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ def _get_global_metrics(self, attack_metrics: list) -> dict:
0.5, m["n_pos_test_examples"], m["n_neg_test_examples"]
)

global_metrics[
"null_auc_3sd_range"
] = f"{0.5 - 3*auc_std:.4f} -> {0.5 + 3*auc_std:.4f}"
global_metrics["null_auc_3sd_range"] = (
f"{0.5 - 3*auc_std:.4f} -> {0.5 + 3*auc_std:.4f}"
)
global_metrics["n_sig_auc_p_vals"] = self._get_n_significant(
auc_p_vals, self.p_thresh
)
Expand Down Expand Up @@ -603,9 +603,9 @@ def _get_attack_metrics_instances(self) -> dict:
attack_metrics_instances["instance_" + str(rep)] = self.attack_metrics[rep]

attack_metrics_experiment["attack_instance_logger"] = attack_metrics_instances
attack_metrics_experiment[
"attack_metric_failfast_summary"
] = self.attack_metric_failfast_summary.get_attack_summary()
attack_metrics_experiment["attack_metric_failfast_summary"] = (
self.attack_metric_failfast_summary.get_attack_summary()
)

return attack_metrics_experiment

Expand All @@ -617,14 +617,14 @@ def _get_dummy_attack_metrics_experiments_instances(self) -> dict:
temp_dummy_attack_metrics = self.dummy_attack_metrics[exp_rep]
dummy_attack_metric_instances = {}
for rep, _ in enumerate(temp_dummy_attack_metrics):
dummy_attack_metric_instances[
"instance_" + str(rep)
] = temp_dummy_attack_metrics[rep]
dummy_attack_metric_instances["instance_" + str(rep)] = (
temp_dummy_attack_metrics[rep]
)
temp = {}
temp["attack_instance_logger"] = dummy_attack_metric_instances
temp[
"attack_metric_failfast_summary"
] = self.dummy_attack_metric_failfast_summary[exp_rep].get_attack_summary()
temp["attack_metric_failfast_summary"] = (
self.dummy_attack_metric_failfast_summary[exp_rep].get_attack_summary()
)
dummy_attack_metrics_experiments[
"dummy_attack_metrics_experiment_" + str(exp_rep)
] = temp
Expand All @@ -643,9 +643,9 @@ def make_report(self) -> dict:
output["metadata"] = self.metadata

output["attack_experiment_logger"] = self._get_attack_metrics_instances()
output[
"dummy_attack_experiments_logger"
] = self._get_dummy_attack_metrics_experiments_instances()
output["dummy_attack_experiments_logger"] = (
self._get_dummy_attack_metrics_experiments_instances()
)

report_dest = os.path.join(self.output_dir, self.report_name)
json_attack_formatter = GenerateJSONModule(report_dest + ".json")
Expand Down
1 change: 1 addition & 0 deletions aisdc/safemodel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Empty file."""

from .reporting import get_reporting_string
1 change: 1 addition & 0 deletions aisdc/safemodel/classifiers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Makes class for various models supported."""

from .dp_svc import DPSVC
from .safedecisiontreeclassifier import SafeDecisionTreeClassifier
from .safekeras import SafeKerasModel
Expand Down
1 change: 1 addition & 0 deletions aisdc/safemodel/classifiers/dp_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
James Liley
21/03/22.
"""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions aisdc/safemodel/classifiers/safekeras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Jim Smith, Andrew McCarty and Richard Preen
UWE 2022.
"""

# general imports


Expand Down
1 change: 0 additions & 1 deletion aisdc/safemodel/classifiers/safetf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
When ready, linting of the imports will be enabled.
"""


# pylint: disable=unused-import
from typing import Any

Expand Down
1,908 changes: 954 additions & 954 deletions development_files/structural_attack.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/lira_attack_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Invoke this code from the root AI-SDC folder with
python -m examples.lira_attack_example
"""

# pylint: disable = duplicate-code

import json
Expand Down
1 change: 1 addition & 0 deletions examples/safemodel_attack_integration_bothcalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Invoke this code from the root AI-SDC folder with
python -m examples.safemodel_attack_integration_bothcalls.
"""

import logging

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions examples/worst_case_attack_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Invoke this code from the root AI-SDC folder with
python -m examples.worst_case_attack_example
"""

import json
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions tests/test_lira_attack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test_lira_attack.py
Copyright (C) Jim Smith2022 <[email protected]>.
"""

# pylint: disable = duplicate-code

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions user_stories/user_story_2/user_story_2_tre.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
NOTE: you should not need to change this file at all, set all parameters via the .yaml file
"""

import argparse
import importlib
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
- Researcher does not save the training/testing data, and therefore the TRE cannot verify the model
"""


import logging
import os

Expand Down

0 comments on commit affb7c7

Please sign in to comment.