Moving-Holiday Lead/Lag Windows¶
holiday_window
¶
Asymmetric pre-holiday build-up and post-holiday slump window covariates.
Generates deterministic distance-to-holiday and distance-from-holiday ramp
features (pre_holiday_window, post_holiday_window,
days_to_next_holiday, days_since_prev_holiday, holiday_offset_days)
around country/custom holiday calendars so both linear and tree-based models
capture multi-day pre-holiday stockpiling and post-holiday demand slumps
rather than only single-day is_holiday spikes.
HolidayWindowConfig
¶
Bases: BaseModel
Configuration for asymmetric pre- and post-holiday window covariates.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Whether to emit holiday-window lead/lag covariates when
|
pre_holiday_days |
int
|
Number of calendar days prior to each holiday date
( |
post_holiday_days |
int
|
Number of calendar days following each holiday date
( |
kernel |
Literal['indicator', 'linear', 'exponential']
|
Shape of the proximity weight curve across the window:
|
from_value
classmethod
¶
Coerce shorthand representations into a :class:HolidayWindowConfig or None.
build_holiday_window_features
¶
Build deterministic pre-holiday build-up and post-holiday slump features.
For each timestamp in dates, computes the calendar-day distance to the
next Strictly Upcoming holiday (d_to >= 1) and from the most recent
Strictly Past holiday (d_since >= 1). Outside the configured
[1, pre_holiday_days] and [1, post_holiday_days] windows, all
returned features are 0.0 so non-holiday baselines remain unperturbed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dates
|
DatetimeIndex | Sequence[Any]
|
Observation timestamps ( |
required |
holiday_df
|
DataFrame | Sequence[Any]
|
DataFrame with a |
required |
window_cfg
|
HolidayWindowConfig | Mapping[str, Any] | bool | Sequence[int] | None
|
:class: |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dictionary mapping each column in :data: |
dict[str, ndarray]
|
1-D |
dict[str, ndarray]
|
|
Source code in src/scale_forecasting/holiday_window.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
coerce_holiday_window_config
¶
Coerce shorthand config representations into a :class:HolidayWindowConfig.
Supports None, bool, (pre_days, post_days) sequences, mappings,
and :class:HolidayWindowConfig instances.
Source code in src/scale_forecasting/holiday_window.py
extract_holiday_day_ordinals
¶
Extract sorted unique integer day ordinals from a holiday frame, date sequence, or ISO country codes.
Source code in src/scale_forecasting/holiday_window.py
holiday_window_columns
¶
Return the deterministic list of holiday-window feature names when active.