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.

WindowAverage

chronax.models.WindowAverage ยท inherits BaseForecaster

Uses the average of the last $k$ observations, with $k$ the length of the window. Wider windows will capture global trends, while narrow windows will reveal local trends. The length of the window selected should take into account the importance of past observations and how fast the series changes.

__init__(self, window_size, alias='WindowAverage', conformal_params=None)

Initializes the WindowAverage model.

Parameter Type Default Description
window_size int - Size of truncated series on which average is estimated.
alias str "WindowAverage" Custom name of the model.
conformal_params Optional[ConformalIntervals] None Information to compute conformal prediction intervals. This is required for generating future prediction intervals.

fit(self, y, X=None) -> Self

Fit the WindowAverage model. Fit an WindowAverage to a time series (numpy array) y and optionally exogenous variables (numpy array) X.

Parameters:

Parameter Type Default Description
y jnp.ndarray - Clean time series of shape (t, ).
X Optional[jnp.ndarray] None Optional exogenous of shape (t, n_x).

Returns: Self (the fitted forecaster; sets self.model_).

predict(self, h, X=None, level=None) -> dict

Predict with fitted WindowAverage.

Parameters:

Parameter Type Default Description
h int - Forecast horizon.
X Optional[jnp.ndarray] None Optional exogenous of shape (h, n_x).
level Optional[List[int]] None Confidence levels (0-100) for prediction intervals.

Returns: dict (Dictionary with entries mean for point predictions and level_* for probabilistic predictions.)

Raises:

Exception Description
ValueError You must pass conformal_params to compute intervals.
ValueError Conformity scores are not available. Fit the model first (fit(...)) with conformal_params set so predict() can use cached scores.

forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict

Memory Efficient WindowAverage predictions. This method avoids memory burden due from object storage. It is analogous to fit_predict without storing information. It assumes you know the forecast horizon in advance.

Parameters:

Parameter Type Default Description
y jnp.ndarray - Clean time series of shape (n, ).
h int - Forecast horizon.
X Optional[jnp.ndarray] None Optional insample exogenous of shape (t, n_x).
X_future Optional[jnp.ndarray] None Optional exogenous of shape (h, n_x).
level Optional[List[int]] None Confidence levels (0-100) for prediction intervals.
fitted bool False Whether or not to return insample predictions.

Returns: dict (Dictionary with entries mean for point predictions and level_* for probabilistic predictions.)

Raises:

Exception Description
Exception You must pass conformal_params to compute them.