OversampleQA
A diagnostic toolkit to validate, audit, and benchmark oversampling methods for imbalanced classification.
Documentation: https://diogoribeiro7.github.io/OversampleQA/
What It Does
- Validates oversampling quality with a hidden-majority error rate (binary and multiclass).
- Offers a broad set of distance metrics (Hassanat, Euclidean, Mahalanobis, etc.).
- Includes optimized and memory-efficient distance matrix computation.
- Supports benchmarking across datasets and oversamplers with exportable results.
- Provides a rich CLI with profiles, templates, shell completion, and diagnostics.
- Extensible via a plugin system for custom metrics and validators.
Concepts
OversampleQA validates synthetic samples by hiding a portion of the majority class and asking whether generated points look more like the hidden majority or the real minority. Each synthetic sample is scored by its nearest-neighbor distance to both groups using a chosen metric. If a synthetic sample is closer to the hidden majority than to the minority, it is counted as an error. The resulting error rate is a direct signal of how often oversampling produces majority-like artifacts. Lower error rates suggest better minority fidelity, but the absolute value depends on the dataset, metric, and hidden ratio. For multiclass data, the same idea generalizes to a confusion-style error matrix across classes.
Install
Python 3.10+ is required. Install the latest release from PyPI:
pip install oversampleqa
For the optional performance helpers:
pip install "oversampleqa[performance]"
For development or unreleased changes, install from source:
git clone https://github.com/diogoribeiro7/OversampleQA.git
cd OversampleQA
poetry install
To depend on the current repository state from another project:
pip install git+https://github.com/diogoribeiro7/OversampleQA.git
Quick Start (Python)
python - <<'PY'
from sklearn.datasets import make_classification
from imblearn.over_sampling import SMOTE
from oversampleqa import validate_oversampling
X, y = make_classification(
n_samples=1000,
n_features=20,
n_informative=10,
n_redundant=10,
n_clusters_per_class=1,
weights=[0.9, 0.1],
random_state=42,
)
error_rate = validate_oversampling(
X=X,
y=y,
minority_label=1,
oversampler=SMOTE(random_state=42),
hidden_ratio=0.1,
metric="hassanat",
)
print(f"SMOTE validation error rate: {error_rate:.3f}")
PY
CLI
oversampleqa --help
oversampleqa validate data.csv \
--target target \
--minority-label 1 \
--oversampler SMOTE \
--metric hassanat \
--hidden-ratio 0.1 \
--export json \
--output runs
oversampleqa profiles
oversampleqa template --template production -o oversampleqa.yaml
oversampleqa benchmark --output benchmark_results
oversampleqa doctor
Legacy minimal CLI (if you prefer a smaller surface):
oversampleqa-validate --help
Configuration
The enhanced CLI loads configuration from ~/.oversampleqa/config.yaml by default. You can override it with --config and select profiles with --profile.
Examples And Docs
- Code samples live in
examples/andtutorials/. - Sphinx documentation sources are in
docs/.
Build docs:
make docs
Development
# One-liner
make setup
# Or run onboarding helper
poetry run python scripts/onboard.py
# Manual steps
poetry install
poetry run pre-commit install
poetry run pre-commit install --hook-type commit-msg
Quality Checks
# Lint and typecheck -- both pass clean
make lint typecheck
# Run tests with coverage
make coverage
# Security audit
make security
# Build docs the way CI does, with warnings as errors
make docs
# Full pre-commit suite
poetry run pre-commit run --all-files
Linting and formatting are handled by ruff alone;
the enforced rule set lives in pyproject.toml. These commands work on Windows
and Linux alike.
Citation
If you use OversampleQA in academic work, please cite it. Machine-readable metadata
lives in CITATION.cff, which GitHub renders as a "Cite this repository" button.
@software{ribeiro_oversampleqa,
author = {Ribeiro, Diogo},
title = {{OversampleQA: a diagnostic toolkit to validate, audit,
and benchmark oversampling methods}},
version = {0.6.0},
year = {2026},
doi = {10.5281/zenodo.21940361},
url = {https://doi.org/10.5281/zenodo.21940361}
}
The DOI above is the concept DOI: it always resolves to the newest archived
version. To cite an exact archived release, use the version DOI listed in
CITATION.cff after Zenodo has minted it. See
Citing OversampleQA for the release and DOI sequence.
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oversampleqa-0.6.0.tar.gz.
File metadata
- Download URL: oversampleqa-0.6.0.tar.gz
- Upload date:
- Size: 121.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
010c238dbaf18a9e9dab9d39bd3c0c64b1f4e3bd7f2fc0e77dfb4590d02d58d0
|
|
| MD5 |
198cee3aa63e63cfd127c06101e09b3f
|
|
| BLAKE2b-256 |
dc2290322a4b13b2bdb88da0a8308743dc089d73139f910e9a7355b8e2055c4a
|
Provenance
The following attestation bundles were made for oversampleqa-0.6.0.tar.gz:
Publisher:
publish.yml on DiogoRibeiro7/OversampleQA
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oversampleqa-0.6.0.tar.gz -
Subject digest:
010c238dbaf18a9e9dab9d39bd3c0c64b1f4e3bd7f2fc0e77dfb4590d02d58d0 - Sigstore transparency entry: 2501542949
- Sigstore integration time:
-
Permalink:
DiogoRibeiro7/OversampleQA@251a4a4ce306db0f80c3402088c7eec6d205cd1b -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/DiogoRibeiro7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@251a4a4ce306db0f80c3402088c7eec6d205cd1b -
Trigger Event:
release
-
Statement type:
File details
Details for the file oversampleqa-0.6.0-py3-none-any.whl.
File metadata
- Download URL: oversampleqa-0.6.0-py3-none-any.whl
- Upload date:
- Size: 135.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceb13f9f521bdc55fa248329614540bbdeac95ad0b8844aaabd60116d4478f6a
|
|
| MD5 |
6ce8522cfb179c28a451b95326e06fd1
|
|
| BLAKE2b-256 |
9c8772b809046e806b2ecdc2d743b0cfbf69307d57d8c8c9256fceed64f601f4
|
Provenance
The following attestation bundles were made for oversampleqa-0.6.0-py3-none-any.whl:
Publisher:
publish.yml on DiogoRibeiro7/OversampleQA
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oversampleqa-0.6.0-py3-none-any.whl -
Subject digest:
ceb13f9f521bdc55fa248329614540bbdeac95ad0b8844aaabd60116d4478f6a - Sigstore transparency entry: 2501542983
- Sigstore integration time:
-
Permalink:
DiogoRibeiro7/OversampleQA@251a4a4ce306db0f80c3402088c7eec6d205cd1b -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/DiogoRibeiro7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@251a4a4ce306db0f80c3402088c7eec6d205cd1b -
Trigger Event:
release
-
Statement type: