LeakLens
Catch data leakage before it fools you. Most "99% accuracy" models are leaking. LeakLens audits both your data and your code, then proves what survives by training three model families on a leak-free pipeline.
What it catches
| Where | Leak |
|---|---|
| Data | Target leakage (a single feature that almost perfectly predicts the label), ID-like columns, train/test row overlap, temporal leakage, entity/group overlap (--group COL) |
Code (.py, .ipynb) |
Scaler/encoder/imputer fitted before the split, SMOTE before the split, transformers fitted on test/validation data |
Every audit returns a 0-100 trust score. The CLI exits with code 1 on a high-severity leak, so it gates CI.
Demo
$ leaklens demo.csv --target is_fraud --arena LeakLens trust score: 50/100 [HIGH] target_leakage :: chargeback_flag :: alone predicts target (roc_auc=1.000) [MEDIUM] id_like :: txn_id :: 100.0% unique values; likely an identifier
Arena ranked by pr_auc (auto-dropped: chargeback_flag, txn_id) model roc_auc pr_auc best_f1 neural_net 0.8374 0.4219 0.4353 linear 0.8410 0.4215 0.4304 tree_ensemble 0.8242 0.3562 0.4103
A leaked column makes accuracy look perfect. LeakLens drops it and shows the honest numbers.
Install
pip install leaklens-ml
Quick start
pip install -e “.[dev,app]” leaklens train.csv --target label --test test.csv --time date leaklens --scan notebooks/ leaklens train.csv --target label --test test.csv --group patient_id python examples/make_demo.py leaklens demo.csv --target is_fraud --arena mlflow ui --backend-store-uri sqlite:///mlflow.db
Model arena
Auto-drops leaking and ID columns, then trains linear, gradient-boosted tree and neural-net models inside leak-safe pipelines (imputation, scaling and encoding are fitted on training data only). Runs are tracked in local MLflow (SQLite) and the winner is saved to models/best.joblib. Add --time COL for a temporal split.
API and UI
uvicorn leaklens.api:app --port 8000 # docs at /docs streamlit run leaklens/ui.py
Endpoints: GET /health, POST /audit, POST /scan, POST /predict.
Docker
docker compose up --build
API on http://localhost:8000/docs, UI on http://localhost:8501.
GitHub Action
- uses: actions/checkout@v4
- uses: eyadstein/leaklens@main
with:
path: notebooks
HTML report
leaklens demo.csv --target is_fraud --arena --html report.html
A single self-contained file with the trust score, findings and arena table. Easy to attach to a PR or share with your team.
Pre-commit hook
repos:
- repo: https://github.com/eyadstein/leaklens
rev: main
hooks:
- id: leaklens
Blocks a commit when a notebook or script fits a transformer before the split.
Trust score badge
leaklens --scan . --badge badge.json
Commit badge.json, then point a shields.io endpoint badge at its raw URL (as at the top of this file).
Architecture
flowchart LR
A[CSV / notebooks] --> B[Data audit + leakage detectors]
A --> C[Static code scanner]
B --> D[Trust score]
C --> D
B --> E[Model arena + MLflow]
E --> F[best.joblib]
F --> G[FastAPI /predict]
D --> H[CLI / Streamlit / GitHub Action]
Roadmap
- Core detectors, static scanner, model arena, API, UI
- Docker, GitHub Action, badge, CI
- Group/entity leakage detector
- PyPI packaging + release workflow (PyPI name
leaklens-ml, command staysleaklens; create a GitHub release to publish)
MIT licensed.
Metadata
Release files for leaklens-ml 0.5.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 | Provenance | |
|---|---|---|---|---|
| leaklens_ml-0.5.0.tar.gz | 18.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| leaklens_ml-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.8 kB
Release files / leaklens_ml-0.5.0.tar.gz
| Download URL | leaklens_ml-0.5.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80fb6605592cbb042222973f7a9cd3278afc7ef45a93de79f844fc522b4bee2d
|
|
BLAKE2b-256 checksum How to use checksums |
6f0b603687da99f598cb8a70e363724e592079d97d116ea07b082647174f352a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / leaklens_ml-0.5.0-py3-none-any.whl
| Download URL | leaklens_ml-0.5.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59fb7fe452bb025ede03a8e6c56763f6e8f5abb8097ff928ea822fc832f2383d
|
|
BLAKE2b-256 checksum How to use checksums |
3c35b27cd2ca56b1dff8814e0b892c9db9b905edaaeb2867dcac98954542e849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for leaklens-ml 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for leaklens_ml-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.