Skip to content

Configuration

Config Class

Config

Bases: BaseModel

Configuration of the Segmenter.

Source code in src/trend_classifier/configuration.py
class Config(BaseModel):
    """Configuration of the Segmenter."""

    N: int = 60
    overlap_ratio: float = 0.33

    # deviation for slope (RAE -> 2, AE -> 100)
    alpha: float | None = 2
    # deviation for offset (RAE -> 2, AE -> 0.25)
    beta: float | None = 2

    # primary metrics to be used for alpha and beta changes from segment to segment
    metrics_for_alpha: Metrics = Metrics.RELATIVE_ABSOLUTE_ERROR
    metrics_for_beta: Metrics = Metrics.RELATIVE_ABSOLUTE_ERROR

Preset Configurations

CONFIG_REL

Relative error for both slope and offset comparison (default behavior).

from trend_classifier.configuration import CONFIG_REL

CONFIG_REL = Config(
    N=40,
    overlap_ratio=0.33,
    alpha=2,
    beta=2,
    metrics_for_alpha=Metrics.RELATIVE_ABSOLUTE_ERROR,
    metrics_for_beta=Metrics.RELATIVE_ABSOLUTE_ERROR,
)

CONFIG_ABS

Absolute error for slope comparison, relative for offset.

from trend_classifier.configuration import CONFIG_ABS

CONFIG_ABS = Config(
    N=40,
    overlap_ratio=0.33,
    alpha=100,
    beta=2,
    metrics_for_alpha=Metrics.ABSOLUTE_ERROR,
    metrics_for_beta=Metrics.RELATIVE_ABSOLUTE_ERROR,
)

CONFIG_REL_SLOPE_ONLY

Only check slope changes, ignore offset.

from trend_classifier.configuration import CONFIG_REL_SLOPE_ONLY

CONFIG_REL_SLOPE_ONLY = Config(
    N=40,
    overlap_ratio=0.33,
    alpha=2,
    beta=None,  # Disabled
    metrics_for_alpha=Metrics.RELATIVE_ABSOLUTE_ERROR,
    metrics_for_beta=Metrics.RELATIVE_ABSOLUTE_ERROR,
)

Metrics Enum

Metrics

Bases: str, Enum

Enum class for metrics used to calculate deviations.

Source code in src/trend_classifier/models.py
class Metrics(str, Enum):
    """Enum class for metrics used to calculate deviations."""

    ABSOLUTE_ERROR = "absolute_error"
    RELATIVE_ABSOLUTE_ERROR = "relative_absolute_error"