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 more powerful drift windowing strategies, warmup and dynamic thresholds #564

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9d71dfb
Add more powerful windowing strategies, warumup and dynamic thresholds
robinholzi Jul 4, 2024
244da67
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Jul 4, 2024
85ed4f5
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Jul 22, 2024
4ca50ed
Add tests
robinholzi Jul 24, 2024
91e0dda
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Jul 24, 2024
28dbb9f
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Jul 26, 2024
6b22b6d
fix linting
robinholzi Jul 26, 2024
0d42176
fix linting
robinholzi Jul 26, 2024
0028e1b
Implement suggestions, v1
robinholzi Aug 7, 2024
9f3b70f
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Aug 7, 2024
bbacf1e
Integrate suggestions, rename things, more tests, documentation
robinholzi Aug 8, 2024
44f29d1
Fix
robinholzi Aug 8, 2024
836af4f
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Aug 12, 2024
f950c25
Fix
robinholzi Aug 12, 2024
8912476
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Aug 12, 2024
c9091aa
Tests and adjustments to warmup
robinholzi Aug 12, 2024
4792fd4
Integrate suggestions, rename things
robinholzi Aug 12, 2024
ed0baaa
fix
robinholzi Aug 12, 2024
ccb6ba3
Fix
robinholzi Aug 13, 2024
46f52d3
Move averaging logic into detector
robinholzi Aug 13, 2024
a2392ad
Merge branch 'main' into robinholzi/feat/more-powerful-drift-windows-…
robinholzi Aug 13, 2024
ea036c1
Final adjustments
robinholzi Aug 14, 2024
9594453
Small fix wrt interval tests
robinholzi Aug 14, 2024
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
8 changes: 3 additions & 5 deletions modyn/config/schema/pipeline/trigger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

from pydantic import Field

from .data_amount import * # noqa
from .data_amount import DataAmountTriggerConfig
from .drift import * # noqa
from .drift import DataDriftTriggerConfig
from .ensemble import * # noqa
from .ensemble import EnsembleTriggerConfig
from .time import * # noqa
from .time import TimeTriggerConfig
from .simple import * # noqa
from .simple import SimpleTriggerConfig

TriggerConfig = Annotated[
TimeTriggerConfig | DataAmountTriggerConfig | DataDriftTriggerConfig | EnsembleTriggerConfig,
SimpleTriggerConfig | DataDriftTriggerConfig | EnsembleTriggerConfig,
Field(discriminator="id"),
]
3 changes: 0 additions & 3 deletions modyn/config/schema/pipeline/trigger/drift/alibi_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ def validate_threshold_permutations(self) -> "AlibiDetectMmdDriftMetric":
+ "or threshold comparison for making drift decisions."
)

if self.threshold is None and self.num_permutations is None:
raise ValueError("Please specify either threshold or num_permutations")

return self


Expand Down
22 changes: 20 additions & 2 deletions modyn/config/schema/pipeline/trigger/drift/config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations

from typing import Annotated, ForwardRef, Literal
from typing import Annotated, ForwardRef, Literal, Self

from pydantic import Field
from pydantic import Field, model_validator

from modyn.config.schema.base_model import ModynBaseModel
from modyn.config.schema.pipeline.trigger.drift.detection_window import (
AmountWindowingStrategy,
DriftWindowingStrategy,
)
from modyn.config.schema.pipeline.trigger.simple import SimpleTriggerConfig

from .aggregation import DriftAggregationStrategy, MajorityVoteDriftAggregationStrategy
from .alibi_detect import AlibiDetectDriftMetric
Expand Down Expand Up @@ -39,6 +40,7 @@ class DataDriftTriggerConfig(ModynBaseModel):
AmountWindowingStrategy(),
description="Which windowing strategy to use for current and reference data",
)

warmup_intervals: int | None = Field(
None,
description=(
Expand All @@ -47,6 +49,13 @@ class DataDriftTriggerConfig(ModynBaseModel):
"a trigger."
),
)
warmup_policy: SimpleTriggerConfig | None = Field(
None,
description=(
"The policy to use for triggering during the warmup phase of the drift policy. "
"Metrics that don't need calibration can ignore this."
),
)

metrics: dict[str, DriftMetric] = Field(
min_length=1,
Expand All @@ -56,3 +65,12 @@ class DataDriftTriggerConfig(ModynBaseModel):
MajorityVoteDriftAggregationStrategy(),
description="The strategy to aggregate the decisions of the individual drift metrics.",
)

@model_validator(mode="after")
def warmup_policy_requirement(self) -> Self:
"""Assert whether the warmup policy is set when a metric needs
calibration."""
for metric in self.metrics.values():
if metric.decision_criterion.needs_calibration and self.warmup_policy is None:
raise ValueError("A warmup policy is required for metrics that need calibration.")
return self
11 changes: 11 additions & 0 deletions modyn/config/schema/pipeline/trigger/simple/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import Annotated

from pydantic import Field

from .data_amount import DataAmountTriggerConfig # noqa
from .time import TimeTriggerConfig # noqa

SimpleTriggerConfig = Annotated[
TimeTriggerConfig | DataAmountTriggerConfig,
Field(discriminator="id"),
]
Loading