Skip to main content

Pre-model data leakage scanner for ML datasets

Project description

LeakProfiler

Pre-model data leakage scanner for machine learning datasets.

LeakProfiler inspects a dataset before training and flags structural/statistical leakage patterns that can inflate model performance. It does not train models, clean data, or do feature engineering—it focuses on leakage risk discovery, explainable risk scoring, and actionable validation guidance.


Release Status

Current release: 1.0.0 (Stable)

This stable release is validated for broad dataset inspection workflows and packaged for standard PyPI installation.


What It Detects

Core detectors

  • Identifier column leakage
  • Duplicate row leakage risk
  • Group leakage risk
  • Temporal leakage risk
  • High feature-target correlation risk
  • High feature importance leakage signals

Reasoning layers

  • Cross-detector reasoning for multi-signal leakage consensus
  • Benign-pattern detection for conservative low-risk context (additive only)

Advisory engine

  • Calibrated risk scoring (weighted by severity/category/confidence)
  • Overlap de-duplication to reduce double-counting
  • Advisory uncertainty estimation
  • Strict HIGH gate: HIGH is emitted only when corroboration + confidence both pass
  • Priority-based next-actions checklist (P1/P2/P3)

Installation

Option A: Install from PyPI (recommended)

pip install leakprofiler==1.0.0

Option B: Local development install

pip install -e .

Optional notebook extras:

pip install "leakprofiler[notebook]"

Quick Start

CLI (installed package)

leakprofiler --file "dataset.csv" --target "TargetColumn"
leakprofiler --file "dataset.csv" --target "TargetColumn" --json
leakprofiler --file "dataset.csv" --target "TargetColumn" --json-path "leakprofiler_report.json"

# Positional shorthand (also supported)
leakprofiler "dataset.csv" "TargetColumn"
leakprofiler "dataset.csv" "TargetColumn" --json

CLI (from source tree)

python src/LeakProfiler.py --file "dataset.csv" --target "TargetColumn" --json
python src/LeakProfiler.py "dataset.csv" "TargetColumn" --json

Python API

from LeakProfiler import run_leakprofiler

run_leakprofiler("dataset.csv", target_column="TargetColumn")

# JSON to stdout
run_leakprofiler("dataset.csv", target_column="TargetColumn", json_stdout=True)

# JSON to file
run_leakprofiler(
    "dataset.csv",
    target_column="TargetColumn",
    json_output_path="leakprofiler_report.json"
)

# Return payload dict
payload = run_leakprofiler(
    "dataset.csv",
    target_column="TargetColumn",
    return_payload=True
)

# Notebook export button
run_leakprofiler(
    "dataset.csv",
    target_column="TargetColumn",
    show_export_button=True,
    export_button_path="leakprofiler_report.json"
)

Backward-compatible alias is still available:

from LeakProfiler import run_leakguard

Output Summary

LeakProfiler renders:

  • Findings summary table
  • Dashboard (risk score, risk level, confidence, stability, uncertainty)
  • Validation advisory panel
  • Advisory basis rationale (top contributors, penalties/bonuses, gate status)
  • Next-actions checklist

JSON export includes:

  • Input metadata
  • Findings list
  • Severity counts and benign count
  • Risk score, risk level, uncertainty
  • Risk rationale and next actions

Detection Design Notes

Cross-detector reasoning

Combines independent signals to produce composite findings such as:

  • Correlation + importance overlap → proxy leakage consensus
  • Identifier + group overlap → entity memorization risk
  • Temporal + predictive overlap → temporal proxy risk
  • Unstable analysis + strong statistical findings → confidence caution

Benign-pattern detection

  • Adds context; does not suppress risk findings
  • Excluded from risk severity totals
  • Conservatively blocked when stronger corroborating risk signals exist

run_leakprofiler Parameters

  • file_path (str, required): CSV path.
  • target_column (str, required): target column name.
  • json_output_path (str, optional): write JSON to file.
  • json_stdout (bool, optional): print JSON to stdout.
  • return_payload (bool, optional): return JSON payload as dict.
  • show_export_button (bool, optional): show notebook export button.
  • export_button_path (str, optional): export path used by notebook button.

Development

Run tests

pytest -q src/test_advisory_engine.py

Stability sweep (100+ datasets)

Run the automated edge-case sweep:

python scripts/stability_sweep.py

Current sweep baseline:

  • total datasets: 128
  • successful runs: 128
  • runtime errors: 0

Results are written to stability_sweep_report.json.

Build package

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

Maintainer: Publish Flow

TestPyPI

python -m twine upload --repository testpypi dist/leakprofiler-1.0.0*

PyPI

python -m twine upload dist/leakprofiler-1.0.0*

Tag suggestion

git tag -a v1.0.0 -m "LeakProfiler 1.0.0 stable"
git push origin v1.0.0

Project Objective

LeakProfiler demonstrates practical, data-centric ML safety engineering:

  • leakage-first dataset inspection,
  • explainable risk diagnostics,
  • conservative false-positive controls,
  • and actionable validation guidance before model training.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leakprofiler-1.0.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leakprofiler-1.0.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file leakprofiler-1.0.0.tar.gz.

File metadata

  • Download URL: leakprofiler-1.0.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for leakprofiler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eaf5300db05fb0ffd557a24a86160fd37f0254a9d5400e006ff857b6e28407cd
MD5 1bf840b4ad4047f408545ccc0c3ec0f0
BLAKE2b-256 b31f1f066d940926a5b213992ea1a8445c9a079a2a7c80b91016a75965e85259

See more details on using hashes here.

File details

Details for the file leakprofiler-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: leakprofiler-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for leakprofiler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db3bb35d8772634eb2f8daa69d0a27e6a8fe28e16f44cddea000a24a3e732a17
MD5 6bd0466eebe8431ed1f404c1480cb98e
BLAKE2b-256 c36ed903eafe23dcd85537b07f3a65f63c9c5c04c2796cba1973b33e7bdd48ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page