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.

TFT

chronax.models.tft_model.TFT · inherits BaseForecaster

TFT forecaster: BaseForecaster wrapper around the flax.nnx backbone. Univariate + exogenous (static / historical / future-known) point and multi-quantile forecasting. Exog sizes are inferred at fit; intervals come from the conformal path (point loss, no temporal exog) or natively from the quantile heads. float32 throughout.

Attributes: * uses_exog: True * alias: TFT * conformal_params: ConformalIntervals | None * model_: TFTNet | None

__init__(self, h, input_size=-1, hidden_size=128, n_head=4, attn_dropout=0.0, dropout=0.1, grn_activation="ELU", rnn_type="lstm", n_rnn_layers=1, max_steps=1000, learning_rate=1e-3, windows_batch_size=1024, scaler_type="robust", loss="mae", quantile_sort=True, random_seed=1, alias="TFT")

Parameter Type Default Description
h - - (undocumented)
input_size int -1 (undocumented)
hidden_size int 128 (undocumented)
n_head int 4 (undocumented)
attn_dropout float 0.0 (undocumented)
dropout float 0.1 (undocumented)
grn_activation str "ELU" (undocumented)
rnn_type str "lstm" (undocumented)
n_rnn_layers int 1 (undocumented)
max_steps int 1000 (undocumented)
learning_rate float 1e-3 (undocumented)
windows_batch_size int 1024 (undocumented)
scaler_type str "robust" (undocumented)
loss str "mae" (undocumented)
quantile_sort bool True (undocumented)
random_seed int 1 (undocumented)
alias str "TFT" (undocumented)

fit(self, y, X=None, *, futr_exog=None, stat_exog=None) -> Self

Parameter Type Default Description
y - - (undocumented)
X - None (undocumented)
futr_exog - None (undocumented)
stat_exog - None (undocumented)

Returns: Self (the fitted forecaster; sets self.model_). Raises: * ValueError: If y is not 1-D. * ValueError: If series length is too short for input_size + h. * ValueError: If historical exog (X) or future exog (futr_exog) shapes do not align with y.

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

Parameter Type Default Description
h - - (undocumented)
X - None (undocumented)
futr_exog - None (undocumented)
level - None (undocumented)

Returns: dict containing forecasts. * If trained with point loss (mae, etc.): {"mean": jnp.ndarray}. If level is provided, includes conformal prediction intervals (lo-L, hi-L). * If trained with quantile loss: {"mean": jnp.ndarray} (median quantile). If level is provided, includes quantile intervals (lo-L, hi-L). Raises: * RuntimeError: If fit(y) has not been called. * ValueError: If h is not positive or exceeds the trained horizon (self.h). * ValueError: If the model was fit with future-known exog, but futr_exog is missing or has the wrong shape. * ValueError: If level is requested when temporal exog is present (conformal prediction limitation). * ValueError: If level is requested but required quantiles were not trained (for quantile loss).

forecast(self, y, h, X=None, X_future=None, *, futr_exog=None, stat_exog=None, level=None, fitted=False) -> dict

Stateless fit-then-predict.

Parameter Type Default Description
y - - (undocumented)
h - - (undocumented)
X - None historical exog over y.
X_future - None future-known exog for the horizon (h, F).
futr_exog - None its history (T, F).
stat_exog - None (undocumented)
level - None (undocumented)
fitted bool False (undocumented)

Returns: dict. Same keys as predict. If fitted=True, includes "fitted": jnp.ndarray. Raises: * NotImplementedError: If fitted=True is requested with any exogenous inputs.