Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

SeasonalWindowAverage

chronax.models.seasonal_window_average.SeasonalWindowAverage ยท inherits BaseForecaster

The SeasonalWindowAverage class implements a forecasting model where predictions are computed by averaging the last window_size complete seasonal cycles for each position in the seasonal period. This JAX implementation is designed for time series with strong, stable seasonal patterns.

Class Attributes: * uses_exog: False (This model does not support exogenous variables) * only_conformal_intervals: True (No native intervals available for this model)

Instance Attributes: * model_: dictionary storing the fitted seasonal pattern of length season_length.

# Hourly data with daily seasonality, averaging last 7 days
from chronax.utils import ConformalIntervals
ci = ConformalIntervals(h=24, n_windows=10)
model = SeasonalWindowAverage(season_length=24, window_size=7, conformal_params=ci)
model.fit(y_train)
forecasts = model.predict(h=24, level=[80, 95])

__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 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.

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 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).