Skip to main content

De-biased validity audit (ER_split) and information-gain benchmark for oversamplers / synthetic minority generators

Project description

resample-audit

De-biased validity audit and information-gain benchmark for oversamplers and synthetic minority generators (SMOTE and its ~100 variants, GAN/VAE/diffusion tabular generators, or anything exposing fit_resample(X, y)).

Why

The standard way to check synthetic minority data compares each synthetic point against the very sample that generated it — the parents sit in the reference, so the check cannot fail. resample-audit measures validity against data the generator has never seen (ER_split, a consistent estimate of the population invalidity 1 − V(G)), and asks the only question that matters in deployment: does the oversampler beat what class weights or a threshold move give for free?

A generator passes the standard only if

  1. valid — the upper Wilson bound of ER_split is below er_max (default 0.10), and
  2. informativeI(G) = F1 over the best trivial baseline (no_resample, class_weight, threshold_move) is positive,

measured with an honest protocol: split first, resample the training half only, evaluate on untouched test data.

Install

pip install resample-audit

Requires only numpy and scikit-learn. imbalanced-learn is optional (for the resamplers themselves).

Use

from imblearn.over_sampling import SMOTE
from resample_audit import audit

report = audit(X, y, SMOTE)        # class, instance, or zero-arg factory
print(report)

report.er_split          # de-biased invalidity estimate (est. 1 - V(G))
report.er_split_ci       # Wilson 95% CI
report.er_naive          # the classical parent-retained check, for contrast
report.info_gain         # F1 over the best trivial baseline
report.delta_brier       # calibration cost (>0 = worse than no_resample)
report.passes_standard   # valid AND informative

Command line:

resample-audit data.csv --resampler imblearn.over_sampling.SMOTE
resample-audit data.csv --no-benchmark --json

CSV = numeric features + a label column (default: last; minority = rarer value unless --minority-label is given).

What the numbers mean

  • ER_naive — share of synthetic points whose nearest real neighbour is majority, judged against the generator's own training sample. Parents are retained in the reference, so this is biased low (often ~0).
  • ER_split — same vote, but the generator sees only half of each class and is judged against the withheld half. Consistent for 1 − V(G); validated against held-out ground truth in the paper (corr 0.79–0.93 across datasets vs 0.13–0.43 for the naive check).
  • bias_gainER_split − ER_naive: the invalidity the classical check hides.
  • I(G) and the deltas — the honest benchmark. PR-AUC/ROC-AUC deltas near zero with a positive F1 delta are the signature of a threshold shift in disguise; Brier/ECE deltas above zero are the calibration cost.

Distance metric defaults to Hassanat (scale-free, the paper's instrument); metric="euclidean" is faster on large data.

Cite

Paper in preparation ("Stop oversampling: a validity theory and a de-biased test", 2026). Earlier instruments: Tarawneh, Hassanat & Altarawneh, "Stop Oversampling for Class Imbalance Learning: A Review", IEEE Access 2022; Hassanat et al., "The Jeopardy of Learning from Over-Sampled Class-Imbalanced Medical Datasets", 2023.

MIT license.

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

resample_audit-0.1.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

resample_audit-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file resample_audit-0.1.0.tar.gz.

File metadata

  • Download URL: resample_audit-0.1.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for resample_audit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5b267f60eff65b9383fb76734bbf84b88d95f775d62f3f8c887c1d980de9406
MD5 0e977da9a556dfb3f76601e23cdc3ce9
BLAKE2b-256 a45b5a456557805212aa34efc86ee7158df1cebafe0b5ac57c4455b1b135b91a

See more details on using hashes here.

File details

Details for the file resample_audit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: resample_audit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for resample_audit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ba96ba46ce54e2de55fa45a3f950f93680f26e1e2e01bbd828a984c386422f2
MD5 a742fae7903d71e6218f26c52ad801d1
BLAKE2b-256 392f5db7e0af490e3c06fc2708c49d6dc742653537ddd48bb90aae7c4bba166a

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