You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: testgen/common/time_series_service.py
+36-21Lines changed: 36 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ def get_sarimax_forecast(
23
23
exclude_weekends: bool=False,
24
24
holiday_codes: list[str] |None=None,
25
25
tz: str|None=None,
26
+
event_space: bool=False,
26
27
) ->pd.DataFrame:
27
28
"""
28
29
# Parameters
@@ -33,30 +34,48 @@ def get_sarimax_forecast(
33
34
:param exclude_weekends: Whether weekends should be considered exogenous when training the model and forecasting.
34
35
:param holiday_codes: List of country or financial market codes defining holidays to be considered exogenous when training the model and forecasting.
35
36
:param tz: IANA timezone (e.g. "America/New_York") for day-of-week/holiday checks. Naive timestamps are treated as UTC and converted to this timezone before determining weekday/holiday status.
37
+
:param event_space: When False (default), resample the series onto a regular calendar grid and
38
+
linearly interpolate gaps before fitting — appropriate for series sampled at a
39
+
steady cadence, and where weekend/holiday exogenous flags apply. When True, fit
40
+
in event-space: one model step per observation, no interpolation, no calendar
41
+
exog. Required for irregularly-spaced series (e.g. the freshness-update points of
42
+
a refresh-driven table) where interpolation would smooth multi-period jumps into
43
+
small uniform increments and collapse the very jump variance the forecast must
44
+
capture.
36
45
37
46
# Return value
38
47
Returns a Pandas dataframe with forecast DatetimeIndex, "mean" column, and "se" (standard error) column.
39
48
"""
40
49
iflen(history) <MIN_TRAIN_VALUES:
41
50
raiseNotEnoughData("Not enough data points in history.")
42
51
43
-
# statsmodels requires DatetimeIndex with a regular frequency
0 commit comments