-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,62 @@ | ||
# Membership Inference Attacks | ||
Python package to create adversarial agents for membership inference attacks againts machine learning models. | ||
Python package to create adversarial agents for membership inference attacks against machine learning models. | ||
|
||
Implementation of the work done by Shokri _et al_: [paper](https://www.cs.cornell.edu/~shmat/shmat_oak17.pdf) | ||
Implementation of the work done by Shokri _et al_ ([paper](https://www.cs.cornell.edu/~shmat/shmat_oak17.pdf)) | ||
|
||
## TO DO | ||
* Basic package outline | ||
* Shadow Model and Attack Model | ||
* Shadow dataset generator using the data synthesis algorithm proposeb by Shokri _et al_ | ||
* Dummy example with Iris dataset | ||
* Expand functionality and generalization of the package | ||
# Examples | ||
Find some examples in `notebooks/` | ||
|
||
The main classes and functions are: | ||
|
||
### Data Synthetiser | ||
|
||
To synthesize data only using a black-box like model `target_model` and predictions using the algorithm proposed by Shokri _et al_ | ||
|
||
```python | ||
from mblearn import synthetize | ||
|
||
x = synthesize(target_model, fixed_class, k_max) | ||
``` | ||
|
||
### Shadow models | ||
Train $n$ shadow models on synthetic data with a given learner. The learner must be a scikit-learn estimator with the `predict_proba` method. | ||
|
||
|
||
```python | ||
from mblearn import ShadowModels | ||
|
||
shadows = ShadowModels(n_models, data, target_classes, learner) | ||
|
||
shadow_data = shadows.results | ||
``` | ||
|
||
### Attacker models | ||
|
||
Using the data generated with the shadow models, trains a attack models | ||
on each label of the shadow dataset. | ||
|
||
```python | ||
from mblearn import AttackerModels | ||
|
||
attacker = AttackModels(target_classes, attack_learner) | ||
|
||
# train the attacker with the shadow data | ||
attacker.fit(shadow_data) | ||
|
||
# query the target model and get the predicted class prob vector | ||
X = target_model.predict_proba(test_data) | ||
|
||
# especulate about the class this test_data belongs to | ||
y = 0 | ||
|
||
# get the prediction: | ||
# True if `test_data` is classified as a member of | ||
# the private model training set for the given class | ||
# False otherwise | ||
attacker.predict(X, y) | ||
``` | ||
Will | ||
|
||
## Warning | ||
|
||
The maturity of the package is far from alpha. This is just a prove of concept and the whole interface and inner wheels may change constantly in the next few months. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .attack_model import AttackModels | ||
from .data_synthesis import synthesize | ||
from .shadow_model import ShadowModels |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from setuptools import setup | ||
|
||
def readme(): | ||
with open('README.md') as readme_file: | ||
return readme_file.read() | ||
|
||
configuration = { | ||
'name' : 'member-learn', | ||
'version': '0.0.1', | ||
'description' : 'Membership inference attacks with sklearn', | ||
'long_description' : readme(), | ||
'classifiers' : [ | ||
'Development Status :: 1 - Planning', | ||
'Intended Audience :: Science/Research', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved', | ||
'Programming Language :: Python', | ||
'Topic :: Software Development', | ||
'Topic :: Scientific/Engineering', | ||
'Operating System :: Microsoft :: Windows', | ||
'Operating System :: POSIX', | ||
'Operating System :: Unix', | ||
'Operating System :: MacOS', | ||
'Programming Language :: Python :: 3.7', | ||
], | ||
'keywords' : 'membership inference adversarial attack privacy machine-learning', | ||
'url' : 'https://github.com/BielStela/membership_inference', | ||
'maintainer' : 'Biel Stela', | ||
'maintainer_email' : '[email protected]', | ||
'license' : 'BSD', | ||
'packages' : ['mblearn'], | ||
'install_requires': ['numpy >= 1.13', | ||
'scikit-learn >= 0.16', | ||
'scipy >= 0.19', | ||
'pandas', | ||
'tqdm'], | ||
'ext_modules' : [], | ||
'cmdclass' : {}, | ||
'data_files' : () | ||
} | ||
|
||
setup(**configuration) |