Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/features/featuresets/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ class ReplenishmentConfig(FeatureConfigBase):
include_days_since_last: Emit days_since_last_replenishment_lag{N}.
include_count_window: Emit replenishment_count_w{W}_lag{N}.
lag_days: Lag offset (>= 1).
count_window_days: Rolling-window size for count features (7-60).
count_window_days: Rolling-window size for count features (3-60).
"""

include_days_since_last: bool = True
include_count_window: bool = True
lag_days: int = Field(default=1, ge=1, le=30, description="Lag offset in days")
count_window_days: int = Field(
default=14,
ge=7,
ge=3,
le=60,
description="Rolling-window size for replenishment count features",
)
Expand Down
8 changes: 4 additions & 4 deletions app/features/featuresets/tests/test_leakage.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ def test_days_since_uses_only_past_events(self) -> None:
def test_count_window_uses_shift_then_rolling(self) -> None:
"""CRITICAL: ``shift(1).rolling(W).sum()`` MUST be the order.

Events on dates 2024-01-01, 2024-01-03, 2024-01-05 with W=7 (the
smallest window the config schema allows; ``ReplenishmentConfig``
bounds ``count_window_days`` at ``ge=7``). Sales rows on every
date 2024-01-01..2024-01-07.
Events on dates 2024-01-01, 2024-01-03, 2024-01-05 with W=7
(comfortably above the ``ReplenishmentConfig`` floor of
``count_window_days >= 3``). Sales rows on every date
2024-01-01..2024-01-07.

Per-row event_count = [1, 0, 1, 0, 1, 0, 0].
Correct ``shift(1).rolling(7, min_periods=1).sum()`` -> NaN at
Expand Down
4 changes: 2 additions & 2 deletions app/features/featuresets/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def test_rejects_lag_days_out_of_bounds(self):
ReplenishmentConfig(lag_days=31)

def test_rejects_count_window_below_min(self):
"""count_window_days below 7 should be rejected."""
"""count_window_days below 3 should be rejected."""
with pytest.raises(ValidationError):
ReplenishmentConfig(count_window_days=6)
ReplenishmentConfig(count_window_days=2)

def test_rejects_count_window_above_max(self):
"""count_window_days above 60 should be rejected."""
Expand Down
2 changes: 1 addition & 1 deletion docs/PHASE/3-FEATURE_ENGINEERING.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ ReplenishmentConfig(
include_days_since_last=True, # default True
include_count_window=True, # default True
lag_days=1, # 1..30
count_window_days=14, # 7..60
count_window_days=14, # 3..60
)
```

Expand Down