SeasonalWindowAverage
chronax.models.seasonal_window_average.SeasonalWindowAverage · inherits BaseForecaster
The SeasonalWindowAverage forecasting model in JAX uses the average of the last k observations of each seasonal period as the forecast, where k = window_size. This implementation is designed for time series with strong, stable seasonal patterns. Key limitations include: it only supports conformal prediction intervals (no native/parametric intervals), it does not support predict_in_sample (fitted values), and it requires at least season_length * window_size observations.
Attributes:
* uses_exog: False (This model does not support exogenous variables)
* alias: Model name, defaults to "SeasWA".
* conformal_params: Optional ConformalIntervals object used to enable conformal intervals.
* season_length: Number of observations per seasonal cycle.
* window_size: Number of recent complete cycles to average.
* only_conformal_intervals: True (Indicates no native intervals exist).
* model_: Dictionary storing the fitted seasonal pattern of length season_length.
__init__(self, season_length: int, window_size: int, alias: str = 'SeasWA', conformal_params: ConformalIntervals | None = None) -> None
Initialize SeasonalWindowAverage model.
| Parameter | Type | Default | Description |
|---|---|---|---|
season_length |
int |
- | Number of observations per seasonal period (e.g., 24 for hourly data with daily seasonality) |
window_size |
int |
- | Number of most recent seasonal cycles to average (e.g., 7 to average the same hour over last 7 days) |
alias |
str |
"SeasWA" |
Custom model name |
conformal_params |
ConformalIntervals \| None |
None |
conformal_intervals object (REQUIRED for computing intervals) |
fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None) -> SeasonalWindowAverage
Fit SeasonalWindowAverage model to time series y.
Computes and stores the seasonal pattern (averages for each position in season). Also sets up fast conformity scoring function for parallel interval computation.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Time series of shape (t,) |
X |
jnp.ndarray \| None |
None |
Ignored (no exogenous support) |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h: int, X: jnp.ndarray | None = None, level: list[int] | None = None) -> dict
Generate h-step ahead forecasts using fitted model.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon (number of steps ahead) |
X |
jnp.ndarray \| None |
None |
Ignored (no exogenous support) |
level |
list[int] \| None |
None |
Confidence levels (0-100) for prediction intervals (e.g., [80, 95]). Requires prediction_intervals to be set. |
Returns: dict with keys:
* 'mean': Point forecasts of shape (h,)
* 'lo-XX': Lower bounds at XX% level (if level specified)
* 'hi-XX': Upper bounds at XX% level (if level specified)
Raises:
* Exception: If level is requested but conformal_params is None.
predict_in_sample(self, level: list[int] | None = None) -> dict
Access fitted in-sample predictions (NOT IMPLEMENTED).
SeasonalWindowAverage does not support fitted values computation.
| Parameter | Type | Default | Description |
|---|---|---|---|
level |
list[int] \| None |
None |
Confidence levels (0-100) for prediction intervals |
Raises:
* NotImplementedError: This method is not supported for SeasonalWindowAverage.
forecast(self, y: jnp.ndarray, h: int, X: jnp.ndarray | None = None, X_future: jnp.ndarray | None = None, level: list[int] | None = None, fitted: bool = False) -> dict
Memory-efficient SeasonalWindowAverage predictions.
This method avoids memory burden from object storage. It is analogous to fit_predict without storing information. It assumes you know the forecast horizon in advance.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Time series of shape (t,) |
h |
int |
- | Forecast horizon |
X |
jnp.ndarray \| None |
None |
Ignored (no exogenous support) |
X_future |
jnp.ndarray \| None |
None |
Ignored (no exogenous support) |
level |
list[int] \| None |
None |
Confidence levels (0-100) for prediction intervals |
fitted |
bool |
False |
Whether to return in-sample predictions (NOT SUPPORTED - will raise error if True) |
Returns: dict with keys:
* 'mean'
* Optional 'lo-XX'/'hi-XX' interval keys
Raises:
* Exception: If level is requested but conformal_params is None.
* NotImplementedError: If fitted=True (not supported).