From 37a099264a49d87614b8ea23ad6972a349e43318 Mon Sep 17 00:00:00 2001 From: Richard Preen Date: Mon, 29 Jul 2024 17:11:33 +0100 Subject: [PATCH] rename aisdc to sacroml --- .github/workflows/lint.yml | 2 +- CHANGELOG.md | 3 ++ CITATION.cff | 32 +++++++++---------- CONTRIBUTING.md | 2 +- README.md | 12 +++---- examples/README.md | 6 ++-- examples/attack_attribute.py | 4 +-- examples/attack_lira.py | 4 +-- examples/attack_worstcase.py | 4 +-- examples/safemodel.py | 4 +-- examples/train_rf_breast_cancer.py | 2 +- examples/train_rf_nursery.py | 2 +- .../user_story_1_researcher_template.py | 5 ++- .../user_story_1/user_story_1_tre.py | 1 - .../user_story_2_researcher_template.py | 3 +- .../user_story_2/user_story_2_tre.py | 1 - .../user_story_3/user_story_3_tre.py | 1 - .../user_story_4/user_story_4_tre.py | 1 - .../user_story_7_researcher_template.py | 5 ++- pyproject.toml | 2 +- {aisdc => sacroml}/__init__.py | 0 {aisdc => sacroml}/attacks/__init__.py | 0 {aisdc => sacroml}/attacks/attack.py | 4 +-- .../attacks/attack_report_formatter.py | 0 .../attacks/attribute_attack.py | 6 ++-- {aisdc => sacroml}/attacks/factory.py | 10 +++--- .../attacks/likelihood_attack.py | 8 ++--- {aisdc => sacroml}/attacks/report.py | 2 +- .../attacks/structural_attack.py | 4 +-- {aisdc => sacroml}/attacks/target.py | 0 .../attacks/worst_case_attack.py | 8 ++--- {aisdc => sacroml}/config/__init__.py | 0 {aisdc => sacroml}/config/attack.py | 4 +-- {aisdc => sacroml}/config/target.py | 4 +-- {aisdc => sacroml}/config/utils.py | 0 {aisdc => sacroml}/main.py | 8 ++--- {aisdc => sacroml}/metrics.py | 0 {aisdc => sacroml}/preprocessing/__init__.py | 0 {aisdc => sacroml}/preprocessing/loaders.py | 0 {aisdc => sacroml}/safemodel/README.md | 0 {aisdc => sacroml}/safemodel/__init__.py | 0 .../safemodel/classifiers/__init__.py | 0 .../safemodel/classifiers/dp_svc.py | 0 .../classifiers/new_model_template.py | 2 +- .../classifiers/safedecisiontreeclassifier.py | 4 +-- .../safemodel/classifiers/safekeras.py | 4 +-- .../classifiers/saferandomforestclassifier.py | 4 +-- .../safemodel/classifiers/safesvc.py | 2 +- .../safemodel/classifiers/safetf.py | 2 +- {aisdc => sacroml}/safemodel/reporting.py | 0 {aisdc => sacroml}/safemodel/rules.json | 0 {aisdc => sacroml}/safemodel/safemodel.py | 4 +-- setup.cfg | 8 ++--- tests/__init__.py | 2 +- tests/attacks/test_attack_report_formatter.py | 2 +- tests/attacks/test_attacks_target.py | 2 +- .../test_attribute_inference_attack.py | 4 +-- tests/attacks/test_factory.py | 4 +-- tests/attacks/test_lira_attack.py | 4 +-- tests/attacks/test_metrics.py | 2 +- tests/attacks/test_report.py | 2 +- tests/attacks/test_structural_attack.py | 4 +-- tests/attacks/test_worst_case_attack.py | 4 +-- tests/conftest.py | 2 +- tests/preprocessing/test_data_interface.py | 2 +- tests/preprocessing/test_loaders.py | 4 +-- tests/safemodel/test_attacks_via_safemodel.py | 4 +-- .../test_safedecisiontreeclassifier.py | 10 +++--- tests/safemodel/test_safekeras2.py | 4 +-- tests/safemodel/test_safemodel.py | 4 +-- .../test_saferandomforestclassifier.py | 4 +-- tests/safemodel/test_safesvc.py | 2 +- tests/safemodel/test_safetf.py | 2 +- 73 files changed, 124 insertions(+), 128 deletions(-) rename {aisdc => sacroml}/__init__.py (100%) rename {aisdc => sacroml}/attacks/__init__.py (100%) rename {aisdc => sacroml}/attacks/attack.py (97%) rename {aisdc => sacroml}/attacks/attack_report_formatter.py (100%) rename {aisdc => sacroml}/attacks/attribute_attack.py (99%) rename {aisdc => sacroml}/attacks/factory.py (84%) rename {aisdc => sacroml}/attacks/likelihood_attack.py (99%) rename {aisdc => sacroml}/attacks/report.py (99%) rename {aisdc => sacroml}/attacks/structural_attack.py (99%) rename {aisdc => sacroml}/attacks/target.py (100%) rename {aisdc => sacroml}/attacks/worst_case_attack.py (99%) rename {aisdc => sacroml}/config/__init__.py (100%) rename {aisdc => sacroml}/config/attack.py (97%) rename {aisdc => sacroml}/config/target.py (98%) rename {aisdc => sacroml}/config/utils.py (100%) rename {aisdc => sacroml}/main.py (86%) rename {aisdc => sacroml}/metrics.py (100%) rename {aisdc => sacroml}/preprocessing/__init__.py (100%) rename {aisdc => sacroml}/preprocessing/loaders.py (100%) rename {aisdc => sacroml}/safemodel/README.md (100%) rename {aisdc => sacroml}/safemodel/__init__.py (100%) rename {aisdc => sacroml}/safemodel/classifiers/__init__.py (100%) rename {aisdc => sacroml}/safemodel/classifiers/dp_svc.py (100%) rename {aisdc => sacroml}/safemodel/classifiers/new_model_template.py (99%) rename {aisdc => sacroml}/safemodel/classifiers/safedecisiontreeclassifier.py (98%) rename {aisdc => sacroml}/safemodel/classifiers/safekeras.py (99%) rename {aisdc => sacroml}/safemodel/classifiers/saferandomforestclassifier.py (98%) rename {aisdc => sacroml}/safemodel/classifiers/safesvc.py (97%) rename {aisdc => sacroml}/safemodel/classifiers/safetf.py (91%) rename {aisdc => sacroml}/safemodel/reporting.py (100%) rename {aisdc => sacroml}/safemodel/rules.json (100%) rename {aisdc => sacroml}/safemodel/safemodel.py (99%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e967f572..41dc8f4e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,5 +23,5 @@ jobs: - name: pylint run: | - pylint -v --recursive=True aisdc tests --fail-under 10 + pylint -v --recursive=True sacroml tests --fail-under 10 ... diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c083bb..5cff93e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Changelog +## Version 1.2.1 (TBC) + Changes: * Rename repository from AI-SDC to SACRO-ML ([#298](https://github.com/AI-SDC/SACRO-ML/pull/298)) +* Rename package from aisdc sacroml ([#298](https://github.com/AI-SDC/SACRO-ML/pull/299)) ## Version 1.2.0 (Jul 11, 2024) diff --git a/CITATION.cff b/CITATION.cff index 600abcdd..a50a4039 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,8 +1,8 @@ cff-version: 1.2.0 -title: AI-SDC -version: 1.2.0 -doi: 10.5281/zenodo.12725798 -date-released: 2024-07-11 +title: SACRO-ML +version: 1.2.1 +doi: +date-released: license: MIT repository-code: https://github.com/AI-SDC/SACRO-ML languages: @@ -55,37 +55,37 @@ identifiers: description: This DOI represents all versions, and will always resolve to the latest one. - type: doi value: 10.5281/zenodo.7080280 - description: This is the archived snapshot of AI-SDC v.1.0.0. + description: This is the archived snapshot of SACRO-ML v.1.0.0. - type: doi value: 10.5281/zenodo.7327390 - description: This is the archived snapshot of AI-SDC v.1.0.1. + description: This is the archived snapshot of SACRO-ML v.1.0.1. - type: doi value: 10.5281/zenodo.7681783 - description: This is the archived snapshot of AI-SDC v.1.0.2. + description: This is the archived snapshot of SACRO-ML v.1.0.2. - type: doi value: 10.5281/zenodo.7886945 - description: This is the archived snapshot of AI-SDC v.1.0.3. + description: This is the archived snapshot of SACRO-ML v.1.0.3. - type: doi value: 10.5281/zenodo.7900410 - description: This is the archived snapshot of AI-SDC v.1.0.4. + description: This is the archived snapshot of SACRO-ML v.1.0.4. - type: doi value: 10.5281/zenodo.8007939 - description: This is the archived snapshot of AI-SDC v.1.0.5. + description: This is the archived snapshot of SACRO-ML v.1.0.5. - type: doi value: 10.5281/zenodo.8172371 - description: This is the archived snapshot of AI-SDC v.1.0.6. + description: This is the archived snapshot of SACRO-ML v.1.0.6. - type: doi value: 10.5281/zenodo.8430143 - description: This is the archived snapshot of AI-SDC v.1.1.0. + description: This is the archived snapshot of SACRO-ML v.1.1.0. - type: doi value: 10.5281/zenodo.10021954 - description: This is the archived snapshot of AI-SDC v.1.1.1. + description: This is the archived snapshot of SACRO-ML v.1.1.1. - type: doi value: 10.5281/zenodo.10055182 - description: This is the archived snapshot of AI-SDC v.1.1.2. + description: This is the archived snapshot of SACRO-ML v.1.1.2. - type: doi value: 10.5281/zenodo.11077535 - description: This is the archived snapshot of AI-SDC v.1.1.3. + description: This is the archived snapshot of SACRO-ML v.1.1.3. - type: doi value: 10.5281/zenodo.12725798 - description: This is the archived snapshot of AI-SDC v.1.2.0. + description: This is the archived snapshot of SACRO-ML v.1.2.0. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c428400d..d1c60565 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ $ pytest . ## Directory Structure -* `aisdc` Contains the aisdc source code. +* `sacroml` Contains the sacroml source code. - `attacks` Contains a variety of privacy attacks on machine learning models. - `preprocessing` Contains preprocessing modules for test datasets. - `safemodel` The safemodel wrappers for common machine learning models. diff --git a/README.md b/README.md index 7cc8a1e7..e20460c6 100644 --- a/README.md +++ b/README.md @@ -2,32 +2,32 @@ [![Latest Version](https://img.shields.io/github/v/release/AI-SDC/SACRO-ML?style=flat)](https://github.com/AI-SDC/SACRO-ML/releases) [![DOI](https://zenodo.org/badge/518801511.svg)](https://zenodo.org/badge/latestdoi/518801511) [![codecov](https://codecov.io/gh/AI-SDC/SACRO-ML/branch/main/graph/badge.svg?token=AXX2XCXUNU)](https://codecov.io/gh/AI-SDC/SACRO-ML) -[![Python versions](https://img.shields.io/pypi/pyversions/aisdc.svg)](https://pypi.org/project/aisdc) +[![Python versions](https://img.shields.io/pypi/pyversions/sacroml.svg)](https://pypi.org/project/sacroml) # SACRO-ML A collection of tools and resources for managing the [statistical disclosure control](https://en.wikipedia.org/wiki/Statistical_disclosure_control) of trained [machine learning](https://en.wikipedia.org/wiki/Machine_learning) models. For a brief introduction, see [Smith et al. (2022)](https://doi.org/10.48550/arXiv.2212.01233). -The `aisdc` package provides: +The `sacroml` package provides: * A variety of privacy attacks for assessing machine learning models. * The safemodel package: a suite of open source wrappers for common machine learning frameworks, including [scikit-learn](https://scikit-learn.org) and [Keras](https://keras.io). It is designed for use by researchers in Trusted Research Environments (TREs) where disclosure control methods must be implemented. Safemodel aims to give researchers greater confidence that their models are more compliant with disclosure control. ## Installation -[![PyPI package](https://img.shields.io/pypi/v/aisdc.svg)](https://pypi.org/project/aisdc) +[![PyPI package](https://img.shields.io/pypi/v/sacroml.svg)](https://pypi.org/project/sacroml) -Install `aisdc` and manually copy the [`examples`](examples/). +Install `sacroml` and manually copy the [`examples`](examples/). To install only the base package, which includes the attacks used for assessing privacy: ``` -$ pip install aisdc +$ pip install sacroml ``` To additionally install the safemodel package: ``` -$ pip install aisdc[safemodel] +$ pip install sacroml[safemodel] ``` Note: macOS users may need to install libomp due to a dependency on XGBoost: diff --git a/examples/README.md b/examples/README.md index 58056f9c..d99606df 100644 --- a/examples/README.md +++ b/examples/README.md @@ -37,14 +37,14 @@ $ python -m examples.attack_lira For example: ``` $ python -m examples.train_rf_nursery -$ aisdc gen-attack -$ aisdc run target_rf_nursery attack.yaml +$ sacroml gen-attack +$ sacroml run target_rf_nursery attack.yaml ``` If you are unable to use the Python `Target` class to generate the `target_dir/` containing the `target.yaml` you can generate one using the CLI tool: ``` -$ aisdc gen-target +$ sacroml gen-target ``` ## User Stories diff --git a/examples/attack_attribute.py b/examples/attack_attribute.py index b3d9bb39..42f513ad 100644 --- a/examples/attack_attribute.py +++ b/examples/attack_attribute.py @@ -10,8 +10,8 @@ import logging -from aisdc.attacks import attribute_attack -from aisdc.attacks.target import Target +from sacroml.attacks import attribute_attack +from sacroml.attacks.target import Target output_dir = "outputs_aia" target_dir = "target_rf_nursery" diff --git a/examples/attack_lira.py b/examples/attack_lira.py index 06869902..70493ffc 100644 --- a/examples/attack_lira.py +++ b/examples/attack_lira.py @@ -18,8 +18,8 @@ import logging -from aisdc.attacks.likelihood_attack import LIRAAttack -from aisdc.attacks.target import Target +from sacroml.attacks.likelihood_attack import LIRAAttack +from sacroml.attacks.target import Target output_dir = "outputs_lira" target_dir = "target_rf_breast_cancer" diff --git a/examples/attack_worstcase.py b/examples/attack_worstcase.py index 3afa5f6e..e0ed108a 100644 --- a/examples/attack_worstcase.py +++ b/examples/attack_worstcase.py @@ -23,8 +23,8 @@ import logging -from aisdc.attacks import worst_case_attack -from aisdc.attacks.target import Target +from sacroml.attacks import worst_case_attack +from sacroml.attacks.target import Target output_dir = "outputs_worstcase" target_dir = "target_rf_breast_cancer" diff --git a/examples/safemodel.py b/examples/safemodel.py index 784b92c6..5e0c3899 100644 --- a/examples/safemodel.py +++ b/examples/safemodel.py @@ -7,8 +7,8 @@ from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder, OneHotEncoder -from aisdc.attacks.target import Target -from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier +from sacroml.attacks.target import Target +from sacroml.safemodel.classifiers import SafeDecisionTreeClassifier output_dir = "outputs_safemodel" diff --git a/examples/train_rf_breast_cancer.py b/examples/train_rf_breast_cancer.py index 48184586..51db749a 100644 --- a/examples/train_rf_breast_cancer.py +++ b/examples/train_rf_breast_cancer.py @@ -6,7 +6,7 @@ from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split -from aisdc.attacks.target import Target +from sacroml.attacks.target import Target output_dir = "target_rf_breast_cancer" diff --git a/examples/train_rf_nursery.py b/examples/train_rf_nursery.py index 4d604872..b9014854 100644 --- a/examples/train_rf_nursery.py +++ b/examples/train_rf_nursery.py @@ -8,7 +8,7 @@ from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder, OneHotEncoder -from aisdc.attacks.target import Target +from sacroml.attacks.target import Target output_dir = "target_rf_nursery" diff --git a/examples/user_stories/user_story_1/user_story_1_researcher_template.py b/examples/user_stories/user_story_1/user_story_1_researcher_template.py index 33a0af6e..0ef393cf 100644 --- a/examples/user_stories/user_story_1/user_story_1_researcher_template.py +++ b/examples/user_stories/user_story_1/user_story_1_researcher_template.py @@ -22,11 +22,10 @@ import numpy as np import pandas as pd -from sklearn.model_selection import train_test_split -from sklearn.preprocessing import LabelEncoder, OneHotEncoder - from aisdc.attacks.target import Target from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier +from sklearn.model_selection import train_test_split +from sklearn.preprocessing import LabelEncoder, OneHotEncoder def main(): diff --git a/examples/user_stories/user_story_1/user_story_1_tre.py b/examples/user_stories/user_story_1/user_story_1_tre.py index 5486fb8e..56327c1f 100644 --- a/examples/user_stories/user_story_1/user_story_1_tre.py +++ b/examples/user_stories/user_story_1/user_story_1_tre.py @@ -13,7 +13,6 @@ import os import yaml - from aisdc.attacks.attack_report_formatter import GenerateTextReport diff --git a/examples/user_stories/user_story_2/user_story_2_researcher_template.py b/examples/user_stories/user_story_2/user_story_2_researcher_template.py index 084c1ec6..6dd819b3 100644 --- a/examples/user_stories/user_story_2/user_story_2_researcher_template.py +++ b/examples/user_stories/user_story_2/user_story_2_researcher_template.py @@ -22,10 +22,9 @@ import numpy as np import pandas as pd -from data_processing_researcher import process_dataset - from aisdc.attacks.target import Target from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier +from data_processing_researcher import process_dataset def run_user_story(): diff --git a/examples/user_stories/user_story_2/user_story_2_tre.py b/examples/user_stories/user_story_2/user_story_2_tre.py index ef632c89..bba59101 100644 --- a/examples/user_stories/user_story_2/user_story_2_tre.py +++ b/examples/user_stories/user_story_2/user_story_2_tre.py @@ -17,7 +17,6 @@ import numpy as np import pandas as pd import yaml - from aisdc.attacks.attack_report_formatter import GenerateTextReport from aisdc.attacks.target import Target diff --git a/examples/user_stories/user_story_3/user_story_3_tre.py b/examples/user_stories/user_story_3/user_story_3_tre.py index 1613c557..fb038cc7 100644 --- a/examples/user_stories/user_story_3/user_story_3_tre.py +++ b/examples/user_stories/user_story_3/user_story_3_tre.py @@ -17,7 +17,6 @@ import numpy as np import yaml - from aisdc.attacks.attack_report_formatter import GenerateTextReport from aisdc.attacks.likelihood_attack import LIRAAttack from aisdc.attacks.target import Target diff --git a/examples/user_stories/user_story_4/user_story_4_tre.py b/examples/user_stories/user_story_4/user_story_4_tre.py index f8e7b0a9..247e1bf9 100644 --- a/examples/user_stories/user_story_4/user_story_4_tre.py +++ b/examples/user_stories/user_story_4/user_story_4_tre.py @@ -15,7 +15,6 @@ import numpy as np import pandas as pd import yaml - from aisdc.attacks.attack_report_formatter import GenerateTextReport from aisdc.attacks.worst_case_attack import WorstCaseAttack diff --git a/examples/user_stories/user_story_7/user_story_7_researcher_template.py b/examples/user_stories/user_story_7/user_story_7_researcher_template.py index f949f7fb..080b0776 100644 --- a/examples/user_stories/user_story_7/user_story_7_researcher_template.py +++ b/examples/user_stories/user_story_7/user_story_7_researcher_template.py @@ -26,11 +26,10 @@ import numpy as np import pandas as pd -from sklearn.model_selection import train_test_split -from sklearn.preprocessing import LabelEncoder, OneHotEncoder - from aisdc.attacks.target import Target from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier +from sklearn.model_selection import train_test_split +from sklearn.preprocessing import LabelEncoder, OneHotEncoder def run_user_story(): diff --git a/pyproject.toml b/pyproject.toml index 4d24817d..56a62895 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,4 +99,4 @@ docstring-code-line-length = 80 [tool.ruff.lint.extend-per-file-ignores] "user_stories/**/*" = ["ANN"] "tests/**/*" = ["S101", "PLR2004", "ANN"] -"aisdc/attacks/structural_attack.py" = ["PLR2004"] +"sacroml/attacks/structural_attack.py" = ["PLR2004"] diff --git a/aisdc/__init__.py b/sacroml/__init__.py similarity index 100% rename from aisdc/__init__.py rename to sacroml/__init__.py diff --git a/aisdc/attacks/__init__.py b/sacroml/attacks/__init__.py similarity index 100% rename from aisdc/attacks/__init__.py rename to sacroml/attacks/__init__.py diff --git a/aisdc/attacks/attack.py b/sacroml/attacks/attack.py similarity index 97% rename from aisdc/attacks/attack.py rename to sacroml/attacks/attack.py index 720f4e3a..c0053283 100644 --- a/aisdc/attacks/attack.py +++ b/sacroml/attacks/attack.py @@ -11,8 +11,8 @@ from fpdf import FPDF -from aisdc.attacks import report -from aisdc.attacks.target import Target +from sacroml.attacks import report +from sacroml.attacks.target import Target logger = logging.getLogger(__name__) diff --git a/aisdc/attacks/attack_report_formatter.py b/sacroml/attacks/attack_report_formatter.py similarity index 100% rename from aisdc/attacks/attack_report_formatter.py rename to sacroml/attacks/attack_report_formatter.py diff --git a/aisdc/attacks/attribute_attack.py b/sacroml/attacks/attribute_attack.py similarity index 99% rename from aisdc/attacks/attribute_attack.py rename to sacroml/attacks/attribute_attack.py index 809e69a2..154bab48 100644 --- a/aisdc/attacks/attribute_attack.py +++ b/sacroml/attacks/attribute_attack.py @@ -12,9 +12,9 @@ from sklearn.base import BaseEstimator from sklearn.preprocessing import OneHotEncoder -from aisdc.attacks import report -from aisdc.attacks.attack import Attack -from aisdc.attacks.target import Target +from sacroml.attacks import report +from sacroml.attacks.attack import Attack +from sacroml.attacks.target import Target logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/aisdc/attacks/factory.py b/sacroml/attacks/factory.py similarity index 84% rename from aisdc/attacks/factory.py rename to sacroml/attacks/factory.py index 74852a7b..e7311765 100644 --- a/aisdc/attacks/factory.py +++ b/sacroml/attacks/factory.py @@ -4,11 +4,11 @@ import yaml -from aisdc.attacks.attribute_attack import AttributeAttack -from aisdc.attacks.likelihood_attack import LIRAAttack -from aisdc.attacks.structural_attack import StructuralAttack -from aisdc.attacks.target import Target -from aisdc.attacks.worst_case_attack import WorstCaseAttack +from sacroml.attacks.attribute_attack import AttributeAttack +from sacroml.attacks.likelihood_attack import LIRAAttack +from sacroml.attacks.structural_attack import StructuralAttack +from sacroml.attacks.target import Target +from sacroml.attacks.worst_case_attack import WorstCaseAttack logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/aisdc/attacks/likelihood_attack.py b/sacroml/attacks/likelihood_attack.py similarity index 99% rename from aisdc/attacks/likelihood_attack.py rename to sacroml/attacks/likelihood_attack.py index 7b7c8b45..da743fd0 100644 --- a/aisdc/attacks/likelihood_attack.py +++ b/sacroml/attacks/likelihood_attack.py @@ -10,10 +10,10 @@ from fpdf import FPDF from scipy.stats import norm, shapiro -from aisdc import metrics -from aisdc.attacks import report -from aisdc.attacks.attack import Attack -from aisdc.attacks.target import Target +from sacroml import metrics +from sacroml.attacks import report +from sacroml.attacks.attack import Attack +from sacroml.attacks.target import Target logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/aisdc/attacks/report.py b/sacroml/attacks/report.py similarity index 99% rename from aisdc/attacks/report.py rename to sacroml/attacks/report.py index a1dba6ea..719ac6c2 100644 --- a/aisdc/attacks/report.py +++ b/sacroml/attacks/report.py @@ -9,7 +9,7 @@ from fpdf import FPDF from pypdf import PdfWriter -from aisdc.attacks.attack_report_formatter import GenerateJSONModule +from sacroml.attacks.attack_report_formatter import GenerateJSONModule # Adds a border to all pdf cells of set to 1 -- useful for debugging BORDER = 0 diff --git a/aisdc/attacks/structural_attack.py b/sacroml/attacks/structural_attack.py similarity index 99% rename from aisdc/attacks/structural_attack.py rename to sacroml/attacks/structural_attack.py index 62bc08a5..d58ea8fb 100644 --- a/aisdc/attacks/structural_attack.py +++ b/sacroml/attacks/structural_attack.py @@ -19,8 +19,8 @@ from sklearn.tree import DecisionTreeClassifier from xgboost.sklearn import XGBClassifier -from aisdc.attacks.attack import Attack -from aisdc.attacks.target import Target +from sacroml.attacks.attack import Attack +from sacroml.attacks.target import Target logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/aisdc/attacks/target.py b/sacroml/attacks/target.py similarity index 100% rename from aisdc/attacks/target.py rename to sacroml/attacks/target.py diff --git a/aisdc/attacks/worst_case_attack.py b/sacroml/attacks/worst_case_attack.py similarity index 99% rename from aisdc/attacks/worst_case_attack.py rename to sacroml/attacks/worst_case_attack.py index c5114841..20441ad8 100644 --- a/aisdc/attacks/worst_case_attack.py +++ b/sacroml/attacks/worst_case_attack.py @@ -10,10 +10,10 @@ from sklearn.metrics import confusion_matrix from sklearn.model_selection import train_test_split -from aisdc import metrics -from aisdc.attacks import report -from aisdc.attacks.attack import Attack, get_class_by_name -from aisdc.attacks.target import Target +from sacroml import metrics +from sacroml.attacks import report +from sacroml.attacks.attack import Attack, get_class_by_name +from sacroml.attacks.target import Target logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/aisdc/config/__init__.py b/sacroml/config/__init__.py similarity index 100% rename from aisdc/config/__init__.py rename to sacroml/config/__init__.py diff --git a/aisdc/config/attack.py b/sacroml/config/attack.py similarity index 97% rename from aisdc/config/attack.py rename to sacroml/config/attack.py index 6127f7b9..e30ac709 100644 --- a/aisdc/config/attack.py +++ b/sacroml/config/attack.py @@ -6,8 +6,8 @@ import yaml -from aisdc.attacks import factory -from aisdc.config import utils +from sacroml.attacks import factory +from sacroml.config import utils def _get_defaults(name: str) -> dict: diff --git a/aisdc/config/target.py b/sacroml/config/target.py similarity index 98% rename from aisdc/config/target.py rename to sacroml/config/target.py index 5a58066d..8be8e90e 100644 --- a/aisdc/config/target.py +++ b/sacroml/config/target.py @@ -6,8 +6,8 @@ import os import sys -from aisdc.attacks.target import Target -from aisdc.config import utils +from sacroml.attacks.target import Target +from sacroml.config import utils arrays_pro = ["X_train", "y_train", "X_test", "y_test"] arrays_raw = ["X", "y", "X_train_orig", "y_train_orig", "X_test_orig", "y_test_orig"] diff --git a/aisdc/config/utils.py b/sacroml/config/utils.py similarity index 100% rename from aisdc/config/utils.py rename to sacroml/config/utils.py diff --git a/aisdc/main.py b/sacroml/main.py similarity index 86% rename from aisdc/main.py rename to sacroml/main.py index 989ca9d5..2ee5434f 100644 --- a/aisdc/main.py +++ b/sacroml/main.py @@ -1,13 +1,13 @@ -"""Main entry point to aisdc.""" +"""Main entry point to sacroml.""" from __future__ import annotations import argparse import os -from aisdc.attacks.factory import run_attacks -from aisdc.config.attack import prompt_for_attack -from aisdc.config.target import prompt_for_target +from sacroml.attacks.factory import run_attacks +from sacroml.config.attack import prompt_for_attack +from sacroml.config.target import prompt_for_target def main() -> None: diff --git a/aisdc/metrics.py b/sacroml/metrics.py similarity index 100% rename from aisdc/metrics.py rename to sacroml/metrics.py diff --git a/aisdc/preprocessing/__init__.py b/sacroml/preprocessing/__init__.py similarity index 100% rename from aisdc/preprocessing/__init__.py rename to sacroml/preprocessing/__init__.py diff --git a/aisdc/preprocessing/loaders.py b/sacroml/preprocessing/loaders.py similarity index 100% rename from aisdc/preprocessing/loaders.py rename to sacroml/preprocessing/loaders.py diff --git a/aisdc/safemodel/README.md b/sacroml/safemodel/README.md similarity index 100% rename from aisdc/safemodel/README.md rename to sacroml/safemodel/README.md diff --git a/aisdc/safemodel/__init__.py b/sacroml/safemodel/__init__.py similarity index 100% rename from aisdc/safemodel/__init__.py rename to sacroml/safemodel/__init__.py diff --git a/aisdc/safemodel/classifiers/__init__.py b/sacroml/safemodel/classifiers/__init__.py similarity index 100% rename from aisdc/safemodel/classifiers/__init__.py rename to sacroml/safemodel/classifiers/__init__.py diff --git a/aisdc/safemodel/classifiers/dp_svc.py b/sacroml/safemodel/classifiers/dp_svc.py similarity index 100% rename from aisdc/safemodel/classifiers/dp_svc.py rename to sacroml/safemodel/classifiers/dp_svc.py diff --git a/aisdc/safemodel/classifiers/new_model_template.py b/sacroml/safemodel/classifiers/new_model_template.py similarity index 99% rename from aisdc/safemodel/classifiers/new_model_template.py rename to sacroml/safemodel/classifiers/new_model_template.py index dad8d4e5..21406dd6 100644 --- a/aisdc/safemodel/classifiers/new_model_template.py +++ b/sacroml/safemodel/classifiers/new_model_template.py @@ -16,7 +16,7 @@ from sklearn.ensemble import ModelToMakeSafer # pylint: disable=E0611 from sklearn.tree import DecisionTreeClassifier -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.safemodel import SafeModel from .safedecisiontreeclassifier import decision_trees_are_equal diff --git a/aisdc/safemodel/classifiers/safedecisiontreeclassifier.py b/sacroml/safemodel/classifiers/safedecisiontreeclassifier.py similarity index 98% rename from aisdc/safemodel/classifiers/safedecisiontreeclassifier.py rename to sacroml/safemodel/classifiers/safedecisiontreeclassifier.py index be6c637f..3e868d7e 100644 --- a/aisdc/safemodel/classifiers/safedecisiontreeclassifier.py +++ b/sacroml/safemodel/classifiers/safedecisiontreeclassifier.py @@ -9,8 +9,8 @@ from dictdiffer import diff from sklearn.tree import DecisionTreeClassifier -from aisdc.safemodel.reporting import get_reporting_string -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.reporting import get_reporting_string +from sacroml.safemodel.safemodel import SafeModel def decision_trees_are_equal( diff --git a/aisdc/safemodel/classifiers/safekeras.py b/sacroml/safemodel/classifiers/safekeras.py similarity index 99% rename from aisdc/safemodel/classifiers/safekeras.py rename to sacroml/safemodel/classifiers/safekeras.py index 7e23fc48..8c86643a 100644 --- a/aisdc/safemodel/classifiers/safekeras.py +++ b/sacroml/safemodel/classifiers/safekeras.py @@ -11,8 +11,8 @@ from tensorflow.keras import Model as KerasModel # pylint: disable = import-error from tensorflow_privacy import compute_dp_sgd_privacy -from aisdc.safemodel.reporting import get_reporting_string -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.reporting import get_reporting_string +from sacroml.safemodel.safemodel import SafeModel warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=FutureWarning) diff --git a/aisdc/safemodel/classifiers/saferandomforestclassifier.py b/sacroml/safemodel/classifiers/saferandomforestclassifier.py similarity index 98% rename from aisdc/safemodel/classifiers/saferandomforestclassifier.py rename to sacroml/safemodel/classifiers/saferandomforestclassifier.py index cd1a1edd..8574fd9f 100644 --- a/aisdc/safemodel/classifiers/saferandomforestclassifier.py +++ b/sacroml/safemodel/classifiers/saferandomforestclassifier.py @@ -7,8 +7,8 @@ import numpy as np from sklearn.ensemble import RandomForestClassifier -from aisdc.safemodel.reporting import get_reporting_string -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.reporting import get_reporting_string +from sacroml.safemodel.safemodel import SafeModel from .safedecisiontreeclassifier import decision_trees_are_equal diff --git a/aisdc/safemodel/classifiers/safesvc.py b/sacroml/safemodel/classifiers/safesvc.py similarity index 97% rename from aisdc/safemodel/classifiers/safesvc.py rename to sacroml/safemodel/classifiers/safesvc.py index 5fe804bc..b3509a77 100644 --- a/aisdc/safemodel/classifiers/safesvc.py +++ b/sacroml/safemodel/classifiers/safesvc.py @@ -7,7 +7,7 @@ import numpy as np from dictdiffer import diff -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.safemodel import SafeModel from .dp_svc import DPSVC diff --git a/aisdc/safemodel/classifiers/safetf.py b/sacroml/safemodel/classifiers/safetf.py similarity index 91% rename from aisdc/safemodel/classifiers/safetf.py rename to sacroml/safemodel/classifiers/safetf.py index 558ac3db..12c6d642 100644 --- a/aisdc/safemodel/classifiers/safetf.py +++ b/sacroml/safemodel/classifiers/safetf.py @@ -2,7 +2,7 @@ from tensorflow_privacy import DPModel -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.safemodel import SafeModel class SafeTFModel(SafeModel, DPModel): diff --git a/aisdc/safemodel/reporting.py b/sacroml/safemodel/reporting.py similarity index 100% rename from aisdc/safemodel/reporting.py rename to sacroml/safemodel/reporting.py diff --git a/aisdc/safemodel/rules.json b/sacroml/safemodel/rules.json similarity index 100% rename from aisdc/safemodel/rules.json rename to sacroml/safemodel/rules.json diff --git a/aisdc/safemodel/safemodel.py b/sacroml/safemodel/safemodel.py similarity index 99% rename from aisdc/safemodel/safemodel.py rename to sacroml/safemodel/safemodel.py index f81e72ff..f236f76e 100644 --- a/aisdc/safemodel/safemodel.py +++ b/sacroml/safemodel/safemodel.py @@ -15,8 +15,8 @@ import joblib from dictdiffer import diff -from aisdc.attacks.factory import attack -from aisdc.attacks.target import Target +from sacroml.attacks.factory import attack +from sacroml.attacks.target import Target # pylint : disable=too-many-branches from .reporting import get_reporting_string diff --git a/setup.cfg b/setup.cfg index ae1634f5..c107a33c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] -name = aisdc -version = 1.2.0 +name = sacroml +version = 1.2.1 description = Tools for the statistical disclosure control of machine learning models long_description = file: README.md long_description_content_type = text/markdown @@ -51,10 +51,10 @@ install_requires = [options.entry_points] console_scripts = - aisdc = aisdc.main:main + sacroml = sacroml.main:main [options.package_data] -aisdc.safemodel = rules.json +sacroml.safemodel = rules.json [options.extras_require] safemodel = diff --git a/tests/__init__.py b/tests/__init__.py index 8980c6b8..715ea789 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""Tests for the aisdc package.""" +"""Tests for the sacroml package.""" diff --git a/tests/attacks/test_attack_report_formatter.py b/tests/attacks/test_attack_report_formatter.py index f2fba435..35f0c894 100644 --- a/tests/attacks/test_attack_report_formatter.py +++ b/tests/attacks/test_attack_report_formatter.py @@ -8,7 +8,7 @@ import pytest -from aisdc.attacks.attack_report_formatter import ( +from sacroml.attacks.attack_report_formatter import ( AnalysisModule, FinalRecommendationModule, GenerateJSONModule, diff --git a/tests/attacks/test_attacks_target.py b/tests/attacks/test_attacks_target.py index 9d044c6c..0db42d9d 100644 --- a/tests/attacks/test_attacks_target.py +++ b/tests/attacks/test_attacks_target.py @@ -6,7 +6,7 @@ import pytest from sklearn.ensemble import RandomForestClassifier -from aisdc.attacks.target import Target +from sacroml.attacks.target import Target RES_DIR = "save_test" diff --git a/tests/attacks/test_attribute_inference_attack.py b/tests/attacks/test_attribute_inference_attack.py index 59ef08e0..4f0b26ac 100644 --- a/tests/attacks/test_attribute_inference_attack.py +++ b/tests/attacks/test_attribute_inference_attack.py @@ -5,8 +5,8 @@ import pytest from sklearn.ensemble import RandomForestClassifier -from aisdc.attacks import attribute_attack -from aisdc.attacks.attribute_attack import ( +from sacroml.attacks import attribute_attack +from sacroml.attacks.attribute_attack import ( _get_bounds_risk, _infer_categorical, _unique_max, diff --git a/tests/attacks/test_factory.py b/tests/attacks/test_factory.py index 619607a4..865da7aa 100644 --- a/tests/attacks/test_factory.py +++ b/tests/attacks/test_factory.py @@ -9,8 +9,8 @@ import yaml from sklearn.ensemble import RandomForestClassifier -from aisdc.attacks.factory import run_attacks -from aisdc.config.attack import _get_attack +from sacroml.attacks.factory import run_attacks +from sacroml.config.attack import _get_attack @pytest.mark.parametrize( diff --git a/tests/attacks/test_lira_attack.py b/tests/attacks/test_lira_attack.py index 019d10ea..7232f98a 100644 --- a/tests/attacks/test_lira_attack.py +++ b/tests/attacks/test_lira_attack.py @@ -8,8 +8,8 @@ from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split -from aisdc.attacks.likelihood_attack import LIRAAttack -from aisdc.attacks.target import Target +from sacroml.attacks.likelihood_attack import LIRAAttack +from sacroml.attacks.target import Target @pytest.fixture(name="dummy_classifier_setup") diff --git a/tests/attacks/test_metrics.py b/tests/attacks/test_metrics.py index e95fd75a..3248ccd5 100644 --- a/tests/attacks/test_metrics.py +++ b/tests/attacks/test_metrics.py @@ -7,7 +7,7 @@ import numpy as np import pytest -from aisdc.metrics import _div, _tpr_at_fpr, get_metrics, min_max_disc +from sacroml.metrics import _div, _tpr_at_fpr, get_metrics, min_max_disc PREDICTED_CLASS = np.array([0, 1, 0, 0, 1, 1]) TRUE_CLASS = np.array([0, 0, 0, 1, 1, 1]) diff --git a/tests/attacks/test_report.py b/tests/attacks/test_report.py index 3bcb7bda..e7b77e0b 100644 --- a/tests/attacks/test_report.py +++ b/tests/attacks/test_report.py @@ -5,7 +5,7 @@ import numpy as np from fpdf import FPDF -from aisdc.attacks import report +from sacroml.attacks import report BORDER = 0 diff --git a/tests/attacks/test_structural_attack.py b/tests/attacks/test_structural_attack.py index 17fc66f6..531802a1 100644 --- a/tests/attacks/test_structural_attack.py +++ b/tests/attacks/test_structural_attack.py @@ -11,8 +11,8 @@ from sklearn.tree import DecisionTreeClassifier from xgboost.sklearn import XGBClassifier -import aisdc.attacks.structural_attack as sa -from aisdc.attacks.target import Target +import sacroml.attacks.structural_attack as sa +from sacroml.attacks.target import Target def get_target(modeltype: str, **kwparams: dict) -> Target: diff --git a/tests/attacks/test_worst_case_attack.py b/tests/attacks/test_worst_case_attack.py index 91ce8787..d20ba1c6 100644 --- a/tests/attacks/test_worst_case_attack.py +++ b/tests/attacks/test_worst_case_attack.py @@ -6,8 +6,8 @@ import pytest from sklearn.svm import SVC -from aisdc.attacks import worst_case_attack -from aisdc.attacks.target import Target +from sacroml.attacks import worst_case_attack +from sacroml.attacks.target import Target def pytest_generate_tests(metafunc): diff --git a/tests/conftest.py b/tests/conftest.py index 83714afc..de2e19f2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,7 +12,7 @@ from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder, OneHotEncoder -from aisdc.attacks.target import Target +from sacroml.attacks.target import Target np.random.seed(1) diff --git a/tests/preprocessing/test_data_interface.py b/tests/preprocessing/test_data_interface.py index 111dfdf7..1f97f93b 100644 --- a/tests/preprocessing/test_data_interface.py +++ b/tests/preprocessing/test_data_interface.py @@ -7,7 +7,7 @@ import pandas as pd import pytest -from aisdc.preprocessing.loaders import UnknownDataset, get_data_sklearn +from sacroml.preprocessing.loaders import UnknownDataset, get_data_sklearn class TestLoaders(unittest.TestCase): diff --git a/tests/preprocessing/test_loaders.py b/tests/preprocessing/test_loaders.py index 34191a3f..7ba6bca9 100644 --- a/tests/preprocessing/test_loaders.py +++ b/tests/preprocessing/test_loaders.py @@ -7,8 +7,8 @@ import pytest -from aisdc.preprocessing import loaders -from aisdc.preprocessing.loaders import DataNotAvailable, UnknownDataset +from sacroml.preprocessing import loaders +from sacroml.preprocessing.loaders import DataNotAvailable, UnknownDataset PROJECT_ROOT_FOLDER = os.path.dirname(os.path.dirname(__file__)) DATA_FOLDER = os.path.join(PROJECT_ROOT_FOLDER, "datasets") diff --git a/tests/safemodel/test_attacks_via_safemodel.py b/tests/safemodel/test_attacks_via_safemodel.py index bf9d360f..0bd12dc5 100644 --- a/tests/safemodel/test_attacks_via_safemodel.py +++ b/tests/safemodel/test_attacks_via_safemodel.py @@ -5,8 +5,8 @@ import numpy as np import pytest -from aisdc.attacks import attribute_attack, likelihood_attack, worst_case_attack -from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier +from sacroml.attacks import attribute_attack, likelihood_attack, worst_case_attack +from sacroml.safemodel.classifiers import SafeDecisionTreeClassifier RES_DIR = "RES" diff --git a/tests/safemodel/test_safedecisiontreeclassifier.py b/tests/safemodel/test_safedecisiontreeclassifier.py index 06485866..e1954c82 100644 --- a/tests/safemodel/test_safedecisiontreeclassifier.py +++ b/tests/safemodel/test_safedecisiontreeclassifier.py @@ -10,11 +10,11 @@ import pytest from sklearn import datasets -from aisdc.attacks import attack -from aisdc.attacks.target import Target -from aisdc.safemodel import reporting -from aisdc.safemodel.classifiers import SafeDecisionTreeClassifier -from aisdc.safemodel.classifiers.safedecisiontreeclassifier import ( +from sacroml.attacks import attack +from sacroml.attacks.target import Target +from sacroml.safemodel import reporting +from sacroml.safemodel.classifiers import SafeDecisionTreeClassifier +from sacroml.safemodel.classifiers.safedecisiontreeclassifier import ( decision_trees_are_equal, get_tree_k_anonymity, ) diff --git a/tests/safemodel/test_safekeras2.py b/tests/safemodel/test_safekeras2.py index 40d12a26..f70d5b29 100644 --- a/tests/safemodel/test_safekeras2.py +++ b/tests/safemodel/test_safekeras2.py @@ -12,8 +12,8 @@ from sklearn.model_selection import train_test_split from tensorflow.keras.layers import Dense, Input # pylint: disable=import-error -from aisdc.safemodel.classifiers import SafeKerasModel, safekeras -from aisdc.safemodel.reporting import get_reporting_string +from sacroml.safemodel.classifiers import SafeKerasModel, safekeras +from sacroml.safemodel.reporting import get_reporting_string warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=FutureWarning) diff --git a/tests/safemodel/test_safemodel.py b/tests/safemodel/test_safemodel.py index c594a6bc..7e010d66 100644 --- a/tests/safemodel/test_safemodel.py +++ b/tests/safemodel/test_safemodel.py @@ -11,8 +11,8 @@ import yaml from sklearn import datasets -from aisdc.safemodel.reporting import get_reporting_string -from aisdc.safemodel.safemodel import SafeModel +from sacroml.safemodel.reporting import get_reporting_string +from sacroml.safemodel.safemodel import SafeModel notok_start = get_reporting_string(name="warn_possible_disclosure_risk") ok_start = get_reporting_string(name="within_recommended_ranges") diff --git a/tests/safemodel/test_saferandomforestclassifier.py b/tests/safemodel/test_saferandomforestclassifier.py index e989d960..2b0e1ff1 100644 --- a/tests/safemodel/test_saferandomforestclassifier.py +++ b/tests/safemodel/test_saferandomforestclassifier.py @@ -9,8 +9,8 @@ import numpy as np from sklearn import datasets -from aisdc.safemodel.classifiers import SafeRandomForestClassifier -from aisdc.safemodel.reporting import get_reporting_string +from sacroml.safemodel.classifiers import SafeRandomForestClassifier +from sacroml.safemodel.reporting import get_reporting_string EXPECTED_ACC = 0.9470198675496688 # 5 estimators, min_samples_leaf 5 diff --git a/tests/safemodel/test_safesvc.py b/tests/safemodel/test_safesvc.py index 864b68e7..79cc5ac2 100644 --- a/tests/safemodel/test_safesvc.py +++ b/tests/safemodel/test_safesvc.py @@ -10,7 +10,7 @@ from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC -from aisdc.safemodel.classifiers import SafeSVC +from sacroml.safemodel.classifiers import SafeSVC def get_data(): diff --git a/tests/safemodel/test_safetf.py b/tests/safemodel/test_safetf.py index 16023289..dbaf8b95 100644 --- a/tests/safemodel/test_safetf.py +++ b/tests/safemodel/test_safetf.py @@ -4,7 +4,7 @@ import pytest -from aisdc.safemodel.classifiers import safetf +from sacroml.safemodel.classifiers import safetf def test_safe_tf_dpmodel_l2_and_noise():