BaseForecaster
base_forecaster.py ยท inherits ABC
BaseForecaster defines the shared interface and common infrastructure for all models in Chronax.
This class implements the core forecaster contract.
Instance Attributes:
* alias: model name, declared in model's __init__.
* conformal_params: a conformal_intervals object, used for prediction intervals.
* model_: stores fitted model post-training.
Class Attributes:
* uses_exog: bool (Default: False). Boolean representing model's exogenous variable handling.
new(self) -> Self
Returns a shallow copy of the object, used internally to clone a model without mutating state.
__repr__(self) -> str
Returns the model's alias for easy identification.
fit(self, y, X=None) -> Self
Fit the model to univariate time series y. Must set self.model_ and return self.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Univariate time series. |
X |
jnp.ndarray | None |
None |
Optional exogenous input. |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h, X=None, level=None) -> dict
Generate h-step-ahead forecasts.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
level |
list[int | float] | None |
None |
(undocumented) |
Returns: dict (Returns a dict with at least {"mean": jnp.ndarray}).
forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict
Stateless fit+predict on y, forecasting h steps ahead. Must return a dict with at least {"mean": jnp.ndarray}. Subclasses may extend the signature with model-specific optional parameters.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
h |
int |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
X_future |
jnp.ndarray | None |
None |
(undocumented) |
level |
list[int | float] | None |
None |
(undocumented) |
fitted |
bool |
False |
(undocumented) |
Returns: dict (Must return a dict with at least {"mean": jnp.ndarray}).
forward(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict
Update the model on new data y and forecast h steps ahead. Default delegates to forecast(). Subclasses with warm-start behavior (e.g. Holt, HoltWinters, ETS) override this.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
h |
int |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
X_future |
jnp.ndarray | None |
None |
(undocumented) |
level |
list[int | float] | None |
None |
(undocumented) |
fitted |
bool |
False |
(undocumented) |
Returns: dict
conformity_scores(self, y, X=None) -> jnp.ndarray
Computes the model's conformity score on y as a 2D JAX array. A model's conformity score is the absolute difference between forecasted and actual values across h positions and n_windows. Uses vmap for parallelization over windows.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
Returns: jnp.ndarray
Raises: ValueError
add_confidence_intervals(fcst, cs, level, method) -> dict
Calculates confidence intervals at level(s) for forceasted values based on conformity_score.
| Parameter | Type | Default | Description |
|---|---|---|---|
fcst |
dict |
- | (undocumented) |
cs |
jnp.ndarray |
- | (undocumented) |
level |
list[int | float] |
- | (undocumented) |
method |
str |
- | (undocumented) |
Returns: dict
Raises: ValueError