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.1 (Stable)

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

What changed in 1.0.1

  • Added a conservative risk floor so strong group/proxy leakage signals are not under-classified as LOW.
  • Fixed correlation threshold calibration to reliably catch perfect proxy features.
  • Expanded validation with diverse column-type scenarios and semantic expectation checks.

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

For reproducible environments, pin an exact version:

pip install leakprofiler==1.0.1

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: 208
  • successful runs: 208
  • runtime errors: 0

Results are written to stability_sweep_report.json.

Semantic expectation sweep

Run expected-outcome matching against generated datasets:

python scripts/semantic_expectation_sweep.py

Current semantic baseline:

  • total datasets: 208
  • passed expectations: 208
  • failed expectations: 0
  • runtime errors: 0

Results are written to semantic_expectation_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.1*

PyPI

python -m twine upload dist/leakprofiler-1.0.1*

Tag suggestion

git tag -a v1.0.1 -m "LeakProfiler 1.0.1 stable"
git push origin v1.0.1

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.1.tar.gz (19.1 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.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: leakprofiler-1.0.1.tar.gz
  • Upload date:
  • Size: 19.1 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.1.tar.gz
Algorithm Hash digest
SHA256 6c1eada389533cea6a6ad4d8258004242562a40f2e1f94ba39cec6c92b90ae35
MD5 85585651320fb15fa0d71c3d085ee5a1
BLAKE2b-256 8a2a5c4e907b8b0d78ff8dfcb62e12e18beec117d9103c12d45f0b3783b141db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: leakprofiler-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2949c65d056c746f4bc8ca37f0893829935f7fcbbe3decdb218405f00e0e39a6
MD5 0c5d9a15ed8765253f9bea2fd00dc932
BLAKE2b-256 80a309150033bbe012dc09e6e4450bb2cac66fd84a84478e6caf2f31e8086c5d

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