🛡️ dataleak-guard
The Fast, Automated Machine Learning Data Leakage & Train-Test Audit Toolkit.
Catch train-test contamination, proxy target leaks, ID memorization, and distribution drift before training breaks production.
📌 Why dataleak-guard?
In Machine Learning and Data Science, Data Leakage is the #1 silent killer of predictive models:
- A model achieves 99.5% accuracy on your Jupyter notebook.
- In production, performance collapses to random chance (52%).
- The culprit? Subtle row overlaps, future variables collected post-event, or improper train-test preprocessing splits.
dataleak-guard audits your train and test datasets in under 1 second, computes a standardized Leakage Risk Score (0–100), and provides actionable remediation fixes.
🚀 Key Features
| Audit Engine | What It Detects | Real-World Danger |
|---|---|---|
| Row Contamination | Exact or hash-identical rows in both train & test sets | Model evaluates on memorized samples, inflating validation metrics |
| Target Leakage | Features with $ | r |
| ID Memorization | High-cardinality IDs (user_id, UUIDs, account numbers) |
Model overfits to individual entity tokens rather than true underlying patterns |
| Preprocessing Drift | Standardized mean shifts & identical pre-split scaling | StandardScaler or encoders fitted on entire dataset before splitting |
| Class Imbalance Shift | Divergence in categorical target class frequencies | Unstratified train-test splits leading to zero-shot test failures |
📦 Installation
pip install dataleak-guard
⚡ Quickstart (Python API)
import dataleak_guard as dlg
from sklearn.model_selection import train_test_split
# Split your data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Audit in 1 line
report = dlg.audit(X_train, X_test, y_train, y_test)
# Display colored terminal dashboard
report.show()
# Export report to Markdown or JSON
print(report.to_markdown())
json_report = report.to_json()
🖥️ Command Line Interface (CLI)
Audit datasets directly from your terminal:
# Audit CSV files
dataleak-guard audit train.csv test.csv --target churn
# Export audit to Markdown report
dataleak-guard audit train.csv test.csv --target churn --output audit_report.md
# Run the live interactive demo
dataleak-guard demo
📊 Terminal Dashboard Preview
╭────────────────────────────────────────────────────────────────────╮
│ 🛡️ DATALEAK-GUARD: ML Data Leakage Audit Report │
│ Train samples: 140 | Features: 5 Test samples: 65 | Features: 5 │
│ Target column: churn │
│ Leakage Risk Score: 88/100 — Status: CRITICAL LEAKAGE DETECTED │
╰────────────────────────────────────────────────────────────────────╯
Detected Leakage Findings & Vulnerabilities
┏━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ S… ┃ Category ┃ Issue Title ┃ Affected ┃ Actionable Fix ┃
┡━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 🚨 │ Row │ Train-Test Row │ - │ Deduplicate dataset before │
│ C… │ Contami… │ Overlap Detected │ │ split or use GroupKFold │
├────┼──────────┼──────────────────┼──────────────┼────────────────────────────┤
│ 🚨 │ Target │ Extreme │ account_clo… │ Drop variables that cannot │
│ C… │ Leakage │ Feature-Target │ │ be observed at inference │
│ │ │ Correlation │ │ time │
├────┼──────────┼──────────────────┼──────────────┼────────────────────────────┤
│ ⚠️ │ Feature │ Identifier │ customer_id │ Remove identifier columns │
│ W… │ Enginee… │ Columns │ │ before model training │
└────┴──────────┴──────────────────┴──────────────┴────────────────────────────┘
🤖 CI/CD Integration (GitHub Actions)
Fail your machine learning training pipeline if data leakage risk exceeds acceptable thresholds:
import sys
import dataleak_guard as dlg
report = dlg.audit(X_train, X_test, y_train, y_test)
if report.risk_score > 30:
print(f"FAILED: Data leakage score {report.risk_score}/100 exceeds safety threshold!")
sys.exit(1)
🛠️ Development & Testing
# Clone the repository
git clone https://github.com/sumit-2007-git/leakdetect.git
cd leakdetect
# Install in editable mode
pip install -e .
# Run test suite
pytest tests -v
# Run linter
ruff check dataleak_guard tests
📄 License
Distributed under the MIT License. See LICENSE for more information.
👤 Author
- Sumit — GitHub (@sumit-2007-git)
Release files for dataleak-guard 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dataleak_guard-0.1.0.tar.gz | 16.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dataleak_guard-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / dataleak_guard-0.1.0.tar.gz
| Download URL | dataleak_guard-0.1.0.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e75f00274bb08525329a9b6946a658d00d5f2aa65f3f782e13640d4a6106bdc
|
|
BLAKE2b-256 checksum How to use checksums |
449da21ab181829fb9618079d10e0ecc3e65fdfa622d7976cb2a10a28752a15f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / dataleak_guard-0.1.0-py3-none-any.whl
| Download URL | dataleak_guard-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
450ab7018afbda6a49e3b7278b5adb27b00759b358b55440a1f2ab1f44670ab4
|
|
BLAKE2b-256 checksum How to use checksums |
66f60302ccf44ba064b571f1fa65e0028b69082c81577b946879f131f8f2cbff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|