Deterministic scientific ML dataset leakage auditor: exact row duplicates, group-ID contamination, temporal look-ahead/embargo violations, Haversine spatial proximity leakage, and target-proxy detection.
- Mission Domain: Scientific Research & Reproducible ML
- Stack: Pure Python 3.11+ (zero runtime third-party dependencies,
mypy --strict,ruff,pytest) - Maintainer: Codesphere Innovations (U) Limited (
codesphere-u)
Peer-reviewed ML models in healthcare, climate, agriculture, and finance are routinely invalidated by subtle train/test leakage (shared patients/farms, shuffled timestamps, nearby spatial clusters, or post-outcome target proxies) that schema validators miss.
LEAK-001Canonical SHA-256 exact duplicate feature row detection across train and test splits.LEAK-002Entity / Group-ID overlap detection (patient_id,farm_id,household_id).LEAK-003Chronological look-ahead and autocorrelation embargo window enforcement.LEAK-004Great-circle WGS84 Haversine spatial-proximity buffer verification (km).LEAK-005Pearson target-proxy correlation scan &LEAK-006order-of-magnitude SI/imperial unit-shift warning.
flowchart LR
A[train.csv & test.csv] --> B[auditor.py]
B --> C[LEAK-001/002<br/>Row Hash & Group Overlap]
B --> D[LEAK-003/004<br/>Temporal Embargo & Haversine]
B --> E[LEAK-005/006<br/>Target Proxy & Unit Shift]
C & D & E --> F[CI Exit Code 0 / 2 + JSON]
See docs/architecture.md for module-level design details.
git clone https://github.com/codesphere-u/leakguard.git
cd leakguard
uv sync --extra devOr install in editable mode with standard pip:
pip install -e ".[dev]"leakguard audit train.csv test.csv --target outcome --group patient_id --time ts --lat lat --lon lon --embargo-hours 24from leakguard import audit_split
rep = audit_split([{"id": "A", "x": 1, "y": 0}], [{"id": "A", "x": 1, "y": 0}], group_col="id", target_col="y")
assert not rep.passeduv run ruff check src tests
uv run mypy src
uv run pytest -v- Security: See SECURITY.md for responsible disclosure procedures.
- Contributing: See CONTRIBUTING.md and CODE_OF_CONDUCT.md.
- Changelog & Roadmap: See CHANGELOG.md and ROADMAP.md.
MIT License — see LICENSE.
Open an issue on GitHub Issues or contact [email protected].