functional.Horizon
The train/forecast split for a single model call.
Usage
functional.Horizon()Replaces the mutable self._* state of the OOP base class with an immutable value derived from the covariate and data shapes via from_data(). The functional primitives (time_series(), predict()) take it as their first argument.
Parameter Attributes
data: Array | Nonet_obs: intfuture: intduration: int
Attributes
data: Array | None-
Observed in-sample data with time at axis
-2(Noneduring pure prior sampling). t_obs: int-
Number of observed (in-sample) time steps
t. future: int-
Number of forecast time steps
f(0while training). duration: int-
Total horizon length
t + future(in time steps).
Attributes
| Name | Description |
|---|---|
| zero_data |
Zeros shaped like data extended to the full horizon.
|
zero_data
Zeros shaped like data extended to the full horizon.
zero_data: Array | None
Mirrors Pyro’s zero_data (and numpyro_forecast.util.zero_data_like()): it exposes the shape/dtype of the data over the forecast horizon without leaking observed values. None when there is no data.
Methods
| Name | Description |
|---|---|
| __post_init__() | Validate that the horizon fields are internally consistent. |
| from_data() | Derive the horizon from covariate and data shapes. |
__post_init__()
Validate that the horizon fields are internally consistent.
Usage
__post_init__()from_data()
Derive the horizon from covariate and data shapes.
Usage
from_data(covariates, data)Parameters
covariates: Array-
Covariates with time at axis
-2spanning the full horizon. data: Array | None-
Observed data with time at axis
-2(Nonefor prior sampling).
Returns
Horizon-
The horizon with
duration = covariates.shape[-2],t_obs = data.shape[-2](or duration whendataisNone), andfuture = duration - t_obs.
Raises
ValueError-
If
datais longer thancovariatesalong the time axis.