Skip to content

oversampleqa.exceptions

oversampleqa.exceptions

Exception hierarchy for OversampleQA.

Every error the package raises deliberately derives from :class:OversampleQAError, so callers can catch the whole family without catching unrelated failures.

These live in their own module rather than in types.py because the error path had been raising ConfigurationError without it being defined anywhere -- a NameError from inside an error handler, which masks the real failure with a confusing one.

OversampleQAError

Bases: Exception

Base class for every error raised by OversampleQA.

Source code in src/oversampleqa/exceptions.py
25
26
class OversampleQAError(Exception):
    """Base class for every error raised by OversampleQA."""

ConfigurationError

Bases: OversampleQAError

Configuration is invalid, missing, or internally inconsistent.

Raised for bad parameter combinations and for lookups of things that were never registered.

Source code in src/oversampleqa/exceptions.py
29
30
31
32
33
34
class ConfigurationError(OversampleQAError):
    """Configuration is invalid, missing, or internally inconsistent.

    Raised for bad parameter combinations and for lookups of things that were
    never registered.
    """

ValidationError

Bases: OversampleQAError

A validation run could not produce a meaningful result.

Covers malformed input as well as data that cannot support the estimand -- for example a minority class too small to hold anything out of.

Source code in src/oversampleqa/exceptions.py
37
38
39
40
41
42
class ValidationError(OversampleQAError):
    """A validation run could not produce a meaningful result.

    Covers malformed input as well as data that cannot support the estimand --
    for example a minority class too small to hold anything out of.
    """

UnsupportedSamplerError

Bases: ValidationError

The oversampler cannot be validated by this package.

Synthetic samples are identified positionally, which requires the sampler to append its output to the data it was given. Combined over/under-samplers such as SMOTEENN and SMOTETomek delete original rows instead, so their synthetic points cannot be identified this way.

Source code in src/oversampleqa/exceptions.py
45
46
47
48
49
50
51
52
class UnsupportedSamplerError(ValidationError):
    """The oversampler cannot be validated by this package.

    Synthetic samples are identified positionally, which requires the sampler
    to append its output to the data it was given. Combined over/under-samplers
    such as ``SMOTEENN`` and ``SMOTETomek`` delete original rows instead, so
    their synthetic points cannot be identified this way.
    """

MetricError

Bases: OversampleQAError

A distance metric could not be resolved or computed.

Source code in src/oversampleqa/exceptions.py
55
56
class MetricError(OversampleQAError):
    """A distance metric could not be resolved or computed."""

PluginError

Bases: OversampleQAError

A plugin failed to register, resolve, or execute.

Source code in src/oversampleqa/exceptions.py
59
60
class PluginError(OversampleQAError):
    """A plugin failed to register, resolve, or execute."""