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.

BatchedForecaster

chronax.batched_forecaster.BatchedForecaster

Multi-series wrapper that fits and forecasts with multiple models. Loops over series sequentially, leveraging JIT-compiled model internals for speed. Accepts dict, 2D array, pandas, or polars DataFrame inputs.

__init__(self, models, id_col='unique_id', time_col='ds', target_col='y')

Initializes the BatchedForecaster with a list of models and column names for DataFrame parsing.

Parameter Type Default Description
models list[BaseForecaster] - Model instances to fit/forecast with.
id_col str 'unique_id' Column name for series identifier (DataFrame input).
time_col str 'ds' Column name for timestamp (DataFrame input).
target_col str 'y' Column name for target values (DataFrame input).

fit(self, data, X=None) -> BatchedForecaster

Fit each model to each series, storing independent fitted copies.

Creates a shallow copy (BaseForecaster.new()) of each model per series so that fitted state is independent across series.

Parameter Type Default Description
data dict[str, jnp.ndarray] \| jnp.ndarray \| np.ndarray \| object - Input time series data in any supported format.
X dict[str, jnp.ndarray] \| None None Per-series in-sample exogenous variables, keyed by series ID. Each value should be shape (n_timesteps, n_features). Series without exogenous data can be omitted from the dict.

Returns: Self (The fitted forecaster).

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

Generate h-step forecasts from fitted models.

| Parameter | Type | Default | Description | |-----------|------intuitive-|-| | h | int | - | Forecast horizon. | | X | dict[str, jnp.ndarray] \| None | None | Per-series future exogenous variables, keyed by series ID. Each value should be shape (h, n_features). | | level | list[int \| float] \| None | None | Confidence levels for prediction intervals (e.g. [80, 95]). |

Returns: dict[str, dict[str, dict]] ({series_id: {model_alias: prediction_dict}}) Raises: ValueError (Must call fit() before predict()).

forecast(self, data, h, X=None, X_future=None, level=None) -> dict[str, dict[str, dict]]

Stateless fit+predict for each model on each series.

Creates a fresh copy of each model per series via new() to prevent cross-series state leakage. Does not store fitted state on self.

Parameter Type Default Description
data dict[str, jnp.ndarray] \| jnp.ndarray \| np.ndarray \| object - Input time series data in any supported format.
h int - Forecast horizon.
X dict[str, jnp.ndarray] \| None None Per-series in-sample exogenous variables, keyed by series ID.
X_future dict[str, jnp.ndarray] \| None None Per-series future exogenous variables, keyed by series ID.
level list[int \| float] \| None None Confidence levels for prediction intervals (e.g. [80, 95]).

Returns: dict[str, dict[str, dict]] ({series_id: {model_alias: prediction_dict}})