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: int, alias: str = 'WindowAverage', conformal_params: Optional[ConformalIntervals] = None) -> 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: jnp.ndarray, X: Optional[jnp.ndarray] = 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 (WindowAverage fitted model. Sets self.model_).

predict(self, h: int, X: Optional[jnp.ndarray] = None, level: Optional[List[int]] = None) -> Dict[str, jnp.ndarray]

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

Return Keys: * mean: jnp.ndarray * lo-L, hi-L: jnp.ndarray (If level is provided, where L is the confidence level)

Raises: * ValueError: If level is requested but conformal_params is None. * ValueError: If level is requested but conformity scores are not available (model not fitted with conformal_params).

forecast(self, y: jnp.ndarray, h: int, X: Optional[jnp.ndarray] = None, X_future: Optional[jnp.ndarray] = None, level: Optional[List[int]] = None, fitted: bool = False) -> Dict[str, jnp.ndarray]

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

Return Keys: * mean: jnp.ndarray * lo-L, hi-L: jnp.ndarray (If level is provided, where L is the confidence level)

Raises: * Exception: If level is requested but conformal_params is None.