TimeXer forecaster: BaseForecaster wrapper around the flax.nnx backbone. Univariate wrapper (n_series=1) over the N-generic patch-transformer network. Point losses; intervals via the conformal path. Normalization lives inside the network (non-stationary norm), so windows train in original scale; optional Box-Cox variance stabilization mirrors the fleet's use_boxcox convention (off = faithful port). Exogenous inputs are not modeled in this port โ without them the reference's cross-attention context is the endogenous variate embedding itself. float32 throughout.
TimeXer
chronax.models.timexer_model.TimeXer ยท inherits BaseForecaster
TimeXer: patch transformer with a global-token exogenous pathway (flax.nnx port of neuralforecast.TimeXer). Wang et al., 2024 โ https://arxiv.org/abs/2402.19072. The endogenous window is patch-embedded per variate with one learnable GLOBAL token appended; encoder layers self-attend over patch tokens while only the global token cross-attends to variate-level embeddings of the full window, and a per-variate flatten head maps the token stack onto the horizon, wrapped in non-stationary normalization. Historic/static exogenous inputs of the reference are not modeled in this port. Point losses; conformal intervals. float32 throughout.
Attributes:
- uses_exog: False
- alias: "TimeXer"
- conformal_params: ConformalIntervals | None
- model_: TimeXerNet | None
__init__(self, h, input_size=-1, patch_len=16, hidden_size=512, n_heads=8, e_layers=2, d_ff=2048, dropout=0.1, use_norm=True, use_boxcox=False, loss='mae', max_steps=1000, learning_rate=0.001, windows_batch_size=32, random_seed=1, alias='TimeXer')
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
- | - | (undocumented) |
input_size |
int |
-1 |
(undocumented) |
patch_len |
int |
16 |
(undocumented) |
hidden_size |
int |
512 |
(undocumented) |
n_heads |
int |
8 |
(undocumented) |
e_layers |
int |
2 |
(undocumented) |
d_ff |
int |
2048 |
(undocumented) |
dropout |
float |
0.1 |
(undocumented) |
use_norm |
bool |
True |
(undocumented) |
use_boxcox |
bool |
False |
(undocumented) |
loss |
str |
"mae" |
(undocumented) |
max_steps |
int |
1000 |
(undocumented) |
learning_rate |
float |
1e-3 |
(undocumented) |
windows_batch_size |
int |
32 |
(undocumented) |
random_seed |
int |
1 |
(undocumented) |
alias |
str |
"TimeXer" |
(undocumented) |
fit(self, y, X=None) -> Self
Trains the TimeXer model using the provided time series y.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
- | - | (undocumented) |
X |
- | None |
(undocumented) |
Returns: Self (the fitted forecaster; sets self.model_).
Raises:
NotImplementedError: If X is provided.
ValueError: If y is not 1-D, too short for the configured input_size, or contains non-positive entries when use_boxcox=True.
predict(self, h, X=None, level=None) -> dict
Generates point forecasts and optional confidence intervals based on the fitted model.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
- | - | (undocumented) |
X |
- | None |
(undocumented) |
level |
- | None |
(undocumented) |
Returns: dict (Keys: {"mean": jnp.ndarray}. If level is provided, includes prediction interval keys.)
Raises:
RuntimeError: If fit(y) has not been called.
ValueError: If h is invalid or exceeds the trained horizon (self.h), or if level is provided but model.conformal_params is missing.
conformity_scores(self, y, X=None)
Walk-forward conformity scores; with use_boxcox=True the CV re-fits reuse the lambda frozen by the eager fit (selection cannot run on traced windows).
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
- | - | (undocumented) |
X |
- | None |
(undocumented) |
Returns: jnp.ndarray (The array of conformity scores.)
Raises:
ValueError: If use_boxcox=True but the estimator has not been fitted.
forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict
Stateless fit-then-predict.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
- | - | (undocumented) |
h |
- | - | (undocumented) |
X |
- | None |
(undocumented) |
X_future |
- | None |
(undocumented) |
level |
- | None |
(undocumented) |
fitted |
bool |
False |
(undocumented) |
Returns: dict (Keys: {"mean": jnp.ndarray}. If level is provided, includes prediction interval keys. If fitted=True, includes {"fitted": jnp.ndarray}.)
Raises:
NotImplementedError: If X or X_future are provided.