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.

TiDEForecaster

chronax.forecaster.TiDEForecaster ยท inherits BaseForecaster

High-level fit/forecast adapter for Chronax TiDE. Mirrors neuralforecast.NeuralForecast(models=[TiDE(...)]).fit(df).predict() with a familiar fit(y) -> self / forecast(y) -> ndarray interface.

__init__(self, h, input_size=-1, hidden_size=512, decoder_output_dim=32, temporal_decoder_dim=128, dropout=0.3, layernorm=True, num_encoder_layers=1, num_decoder_layers=1, temporal_width=4, futr_exog_size=0, hist_exog_size=0, stat_exog_size=0, output_size=1, *, max_steps=1000, learning_rate=0.001, batch_size=1024, random_seed=0, alias='TiDE', loss='mae', scale=True, global_scale=False, use_std_scaler=True, grad_clip=0.0, weight_decay=0.0, use_lr_schedule=False, window_sampling=True, val_fraction=0.1, val_check_steps=100, early_stop_patience_steps=-1)

Initializes the TiDE forecaster configuration and training parameters.

Parameter Type Default Description
h int - Forecast horizon.
input_size int -1 History window length; -1 (default) uses 3 * h.
hidden_size int 512 forwarded to :class:TiDEConfig.
decoder_output_dim int 32 forwarded to :class:TiDEConfig.
temporal_decoder_dim int 128 forwarded to :class:TiDEConfig.
dropout float 0.3 forwarded to :class:TiDEConfig.
layernorm bool True forwarded to :class:TiDEConfig.
num_encoder_layers int 1 forwarded to :class:TiDEConfig.
num_decoder_layers int 1 forwarded to :class:TiDEConfig.
temporal_width int 4 forwarded to :class:TiDEConfig.
futr_exog_size int 0 forwarded to :class:TiDEConfig.
hist_exog_size int 0 forwarded to :class:TiDEConfig.
stat_exog_size int 0 forwarded to :class:TiDEConfig.
output_size int 1 forwarded to :class:TiDEConfig.
max_steps int 1000 Total optimiser steps.
learning_rate float 1e-3 Adam(W) peak learning rate.
batch_size int 1024 Windows sampled per training step.
random_seed int 0 PRNG seed for parameter init and window sampling.
alias str "TiDE" Display name for external reporting.
loss Union[str, LossFn] "mae" Registered name ("mae", "mse") from :mod:chronax.models.tide.loss or a callable (y, y_hat) -> scalar.
scale bool True Apply per-window RobustScaler during training and inference. Strongly recommended; matches NeuralForecast's scaler_type.
global_scale bool False (undocumented)
use_std_scaler Optional[bool] True (undocumented)
grad_clip float 0.0 Global gradient-norm clip (0 = disabled).
weight_decay float 0.0 AdamW weight decay (0 = plain Adam).
use_lr_schedule bool False Warmup-cosine LR schedule; False = constant LR.
window_sampling bool True Use all rolling windows (True, recommended) vs only the last window per series (False).
val_fraction float 0.1 Fraction of windows held out for validation (0 = none).
val_check_steps int 100 Evaluate validation loss every this many steps.
early_stop_patience_steps int -1 Stop when val loss does not improve for this many consecutive checks; -1 = disabled.

fit(self, y, *, verbose=False) -> Self

Train the model in-place on y.

All rolling windows are extracted from every series long enough to yield at least one window. Per-window RobustScaler is applied inside the JIT-compiled train_step_windows.

Parameters:

Parameter Type Default Description
y SeriesLike - A single 1-D series or a list of 1-D series (panel mode).
verbose bool False Print loss every max(1, max_steps // 10) steps.

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

forecast(self, y=None, h=None) -> jnp.ndarray

Produce point forecasts from the last input_size of each series.

Per-window RobustScaler statistics are computed on the last input_size observations of each series (matching the scaler applied during training) and the forecast is inverse-transformed before return.

Parameters:

Parameter Type Default Description
y Optional[SeriesLike] None Series to forecast for (required).
h Optional[int] None Horizon override โ€” must match config.h if provided.

Returns: jnp.ndarray of shape [h] for univariate input or [n_series, h] for panel input.

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

Forecast from the series passed to :meth:fit.

Satisfies the BaseForecaster contract: unlike :meth:forecast, this does not take y explicitly โ€” it reuses the series cached at fit time.

Parameters:

Parameter Type Default Description
h Optional[int] None Forecast horizon. Defaults to config.h when None.
X Optional[jnp.ndarray] None Reserved for future exogenous regressors; unused.
level Optional[List[Union[int, float]]] None Not yet supported for this model.

Returns: dict: {"mean": jnp.ndarray}.

Raises: NotImplementedError: TiDEForecaster.predict(level=...) is not yet supported.

fit_predict(self, y, **kwargs) -> jnp.ndarray

Fit on y and immediately forecast for the same series.

Parameters:

Parameter Type Default Description
y SeriesLike - (undocumented)
**kwargs - (undocumented)

Returns: jnp.ndarray (undocumented).

with_config(self, **overrides) -> TiDEForecaster

Return a fresh (unfitted) forecaster with overridden config fields.

Parameters:

Parameter Type Default Description
**overrides - (undocumented)

Returns: TiDEForecaster (undocumented).