Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add thresholdType to StddevConfig #52

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions whylabs_toolkit/monitor/models/analyzer/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ class _ThresholdBaseConfig(AlgorithmConfig):
)


class ThresholdType(str, Enum):
"""By default, an anomaly will be generated when the target is above or below the baseline
by the specified threshold.

If its only desirable to alert when the target is above the
baseline and not the other way around, specify upper for your ThresholdType."""

lower = "lower" # type: ignore
upper = "upper" # type: ignore


class StddevConfig(_ThresholdBaseConfig):
"""Calculates upper bounds and lower bounds based on stddev from a series of numbers.

Expand All @@ -253,6 +264,7 @@ class StddevConfig(_ThresholdBaseConfig):
factor: Optional[float] = Field(
3.0, description="The multiplier used with stddev to build the upper and lower bounds."
)
thresholdType: Optional[ThresholdType]
minBatchSize: Optional[int] = Field(
1, title="MinBatchSize", ge=1, description="Minimum number of batches that is required"
)
Expand Down Expand Up @@ -364,17 +376,6 @@ class DiffMode(str, Enum):
pct = "pct"


class ThresholdType(str, Enum):
"""By default, an anomaly will be generated when the target is above or below the baseline
by the specified threshold.

If its only desirable to alert when the target is above the
baseline and not the other way around, specify upper for your ThresholdType."""

lower = "lower" # type: ignore
upper = "upper" # type: ignore


class DiffConfig(AlgorithmConfig):
"""Detecting the differences between two numerical metrics."""

Expand Down