๐ฏ What is privacylens?
Most ML engineers don't know if their model is leaking private training data. privacylens audits it.
from privacylens import audit
report = audit(model, X_train, y_train, X_test)
report.summary()
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ privacylens โ Privacy Audit Report โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโค
โ Check โ Score โ Risk โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ Membership Inference Attack โ 0.087 โ LOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
Model: RandomForestClassifier
Overall Risk: LOW
โข MIA advantage score: 0.087 โ model shows low Membership Inference vulnerability.
โจ Features
- ๐ต๏ธ Membership Inference Attack (MIA) โ Detect if an attacker can identify training records using a shadow model approach (Shokri et al., 2017)
- ๐ Framework agnostic โ Works with scikit-learn, XGBoost, and any model with
predict_proba() - ๐จ Beautiful terminal output โ Rich colour-coded risk tables with LOW / MEDIUM / HIGH classification
- ๐ค CLI + Python API โ Use in scripts or integrate into CI/CD pipelines
- ๐ JSON output โ Machine-readable results for dashboards and reporting
Coming in future releases:
- ๐ข PII leakage detection in model embeddings
- ๐ Model inversion risk scoring
- ๐ค HuggingFace Transformers adapter
- ๐ HTML compliance report export
๐ฆ Installation
# Base install (scikit-learn models)
pip install privacyaudit
# With PyTorch support
pip install "privacyaudit[torch]"
# With XGBoost support
pip install "privacyaudit[xgboost]"
# Everything
pip install "privacyaudit[all]"
Note: The PyPI package is
privacyaudit. Import asfrom privacylens import audit.
๐ Quick Start
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from privacylens import audit
# Train a model
X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
# Audit it for privacy vulnerabilities
report = audit(model, X_train, y_train, X_test, y_test)
report.summary()
# Get results as dict (for JSON logging)
print(report.to_dict())
๐ฅ๏ธ CLI Usage
# Audit a saved model
privacylens audit model.pkl train.csv test.csv
# JSON output for CI/CD integration
privacylens audit model.pkl train.csv test.csv --output json
# Skip MIA check
privacylens audit model.pkl train.csv test.csv --no-mia
๐๏ธ Architecture
privacylens/
โโโ src/privacylens/
โ โโโ __init__.py # Public API: audit(), AuditReport
โ โโโ auditor.py # Main orchestrator
โ โโโ attacks/
โ โ โโโ membership.py # MIA engine (shadow model + attack classifier)
โ โโโ cli.py # Click CLI
โโโ tests/
โโโ test_auditor.py
โโโ test_membership.py
๐ Risk Score Interpretation
| MIA Score | Risk Level | Meaning |
|---|---|---|
0.0 โ 0.10 |
๐ข LOW | Model reveals minimal membership information |
0.10 โ 0.30 |
๐ก MEDIUM | Some memorisation risk โ review training data |
0.30 โ 1.00 |
๐ด HIGH | Model likely memorising training records |
๐ค Contributing
See CONTRIBUTING.md. All contributions welcome!
๐ License
MIT โ see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file privacyaudit-0.1.1.tar.gz.
File metadata
- Download URL: privacyaudit-0.1.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
291fca566561319ca27e3a139fab1e0fa8567cefe123a9e0685650a5dabd2707
|
|
| MD5 |
f08f1ce4e9f881c6b15600523b7317de
|
|
| BLAKE2b-256 |
f5698a61cdb93422041c10af0f720f4e157fea3ffc7491e09fc33a3252e98f3d
|
Provenance
The following attestation bundles were made for privacyaudit-0.1.1.tar.gz:
Publisher:
release.yml on nithin42/privacylens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
privacyaudit-0.1.1.tar.gz -
Subject digest:
291fca566561319ca27e3a139fab1e0fa8567cefe123a9e0685650a5dabd2707 - Sigstore transparency entry: 2306167425
- Sigstore integration time:
-
Permalink:
nithin42/privacylens@8b67dc01bd6280fef4cb4a21d34bb2c39dea646a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b67dc01bd6280fef4cb4a21d34bb2c39dea646a -
Trigger Event:
push
-
Statement type:
File details
Details for the file privacyaudit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: privacyaudit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
329abcbdb9c00395c3fd4d08047e4888d7f286d5684524f341abfb8d5fe9afa1
|
|
| MD5 |
279c174b1aab990efbef2af2f3193f67
|
|
| BLAKE2b-256 |
bcfeed1c3d133ed3c2a0cd89b534d4d34ffb33786511fc727ccea3d976802e10
|
Provenance
The following attestation bundles were made for privacyaudit-0.1.1-py3-none-any.whl:
Publisher:
release.yml on nithin42/privacylens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
privacyaudit-0.1.1-py3-none-any.whl -
Subject digest:
329abcbdb9c00395c3fd4d08047e4888d7f286d5684524f341abfb8d5fe9afa1 - Sigstore transparency entry: 2306167556
- Sigstore integration time:
-
Permalink:
nithin42/privacylens@8b67dc01bd6280fef4cb4a21d34bb2c39dea646a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b67dc01bd6280fef4cb4a21d34bb2c39dea646a -
Trigger Event:
push
-
Statement type: