MCPcopy Create free account
hub / github.com/TrustAIResearch/MLHospital

github.com/TrustAIResearch/MLHospital @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
279 symbols 742 edges 33 files ⚖ MIT 41 documented · 15% updated 3y ago★ 441 open issues

Browse by type

Functions 225 Types & classes 54
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

MLHospital

MLHospital is a repo to evaluate inference attacks and the corresponding defenses against machine learning models.

Currently we support membership inference attacks and attribute inference attacks.

Installation

git clone https://github.com/TrustAIResearch/MLHospital.git;
cd MLHospital;
conda env create -f environment.yml;
conda activate ml-hospital;
python setup.py install;

Membership inference attacks

Step 0: train target/shadow models

cd MLHospital/mlh/examples;
python train_target_models.py --mode target;
python train_target_models.py --mode shadow;

Note that you can also specify the --training_type with different defense mechanisms, e.g., Normal, LabelSmoothing, AdvReg, DP, MixupMMD, and PATE.

Step 1: perform membership inference attacks

python mia_example.py 

Note that you can also specify the --attack_type with different attacks, e.g., black-box, black-box-sorted, black-box-top3, metric-based, and label-only.

Attribute inference attacks

cd MLHospital/mlh/examples;
python3 aia_example.py --task aia --dataset CelebA --defense AdvTrain --alpha 1.0;

The aia_example.py first trains target models (with or without defense), then trains and evaluates the attack model.

In this example, CelebA dataset is used, and the defense method and alpha (the hyperparameter to balance utility and privacy) are set to be AdvTrain and 1.0, respectively. Note that you can also specify the --defense with different defense mechanisms, e.g., Normal, AdvTrain, Olympus, and AttriGuard.

Authors

The tool is designed and developed by Xinlei He (CISPA), Zheng Li (CISPA), Yukun Jiang (CISPA), Yun Shen (NetApp), and Yang Zhang (CISPA).

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 185
Class 54
Function 40

Languages

Python100%

Modules by API surface

mlh/attacks/membership_inference/attacks.py41 symbols
mlh/data_preprocessing/data_loader.py36 symbols
mlh/attacks/attribute_inference/attacks.py30 symbols
mlh/defenses/attribute_inference/Olympus.py20 symbols
mlh/defenses/attribute_inference/AttriGuard.py20 symbols
mlh/defenses/membership_inference/PATE.py15 symbols
mlh/defenses/attribute_inference/AdvTrain.py15 symbols
mlh/defenses/pate.py14 symbols
mlh/models/attack_model.py12 symbols
mlh/defenses/membership_inference/MixupMMD.py10 symbols
mlh/defenses/membership_inference/AdvReg.py9 symbols
mlh/models/utils.py8 symbols

For agents

$ claude mcp add MLHospital \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page