Autoformer
chronax.models.autoformer.forecaster · inherits BaseForecaster
Univariate Autoformer forecaster (JAX/Flax Linen port of neuralforecast.Autoformer).
Maintenance status: Active univariate forecaster. Integrates with the BaseForecaster interface, including conformal prediction intervals via predict(level=...). Defaults match neuralforecast.Autoformer.
Attributes
| Attribute | Type | Description |
|---|---|---|
uses_exog |
bool |
False |
alias |
str |
Alias used for logging and identification. |
conformal_params |
ConformalIntervals | None |
Parameters used for conformal prediction intervals. |
model_ |
TrainState | None |
The fitted Flax training state. |
__init__(self, h: int, input_size: int = -1, hidden_size: int = 128, n_heads: int = 4, factor: int = 3, moving_avg_window: int = 25, encoder_layers: int = 2, decoder_layers: int = 1, conv_hidden_size: int = 32, decoder_input_size_multiplier: float = 0.5, dropout: float = 0.05, activation: str = 'gelu', max_steps: int = 1000, learning_rate: float = 0.0001, batch_size: int = 32, num_lr_decays: int = 3, val_fraction: float = 0.1, val_check_steps: int = 100, early_stop_patience_steps: int = -1, grad_clip: float = 1.0, weight_decay: float = 0.0, random_seed: int = 1, alias: str = 'Autoformer', loss: Union[str, LossFn] = 'mae')
(undocumented)
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | (undocumented) |
input_size |
int |
-1 |
(undocumented) |
hidden_size |
int |
128 |
(undocumented) |
n_heads |
int |
4 |
(undocumented) |
factor |
int |
3 |
(undocumented) |
moving_avg_window |
int |
25 |
(undocumented) |
encoder_layers |
int |
2 |
(undocumented) |
decoder_layers |
int |
1 |
(undocumented) |
conv_hidden_size |
int |
32 |
(undocumented) |
decoder_input_size_multiplier |
float |
0.5 |
(undocumented) |
dropout |
float |
0.05 |
(undocumented) |
activation |
str |
'gelu' |
(undocumented) |
max_steps |
int |
1000 |
(undocumented) |
learning_rate |
float |
0.0001 |
(undocumented) |
batch_size |
int |
32 |
(undocumented) |
num_lr_decays |
int |
3 |
(undocumented) |
val_fraction |
float |
0.1 |
(undocumented) |
val_check_steps |
int |
100 |
(undocumented) |
early_stop_patience_steps |
int |
-1 |
(undocumented) |
grad_clip |
float |
1.0 |
(undocumented) |
weight_decay |
float |
0.0 |
(undocumented) |
random_seed |
int |
1 |
(undocumented) |
alias |
str |
'Autoformer' |
(undocumented) |
loss |
Union[str, LossFn] |
'mae' |
(undocumented) |
fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None) -> Self
Fit on a univariate 1-D series.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
Returns: Self (the fitted forecaster; sets self.model_).
Raises: NotImplementedError (if X is not None), ValueError (if y is not 1-D or too short).
predict(self, h: int, X: jnp.ndarray | None = None, level: list[int | float] | None = None) -> dict
Forecast h steps from the fitted context.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | (undocumented) |
X |
jnp.ndarray | None |
None |
(undocumented) |
level |
list[int | float] | None |
None |
(undocumented) |
Returns: dict containing the forecast.
| Key | Type | Description |
|---|---|---|
"mean" |
jnp.ndarray |
The point forecast of shape (h,). |
lower_<level> |
jnp.ndarray |
Lower bound of the prediction interval (if level is provided). |
upper_<level> |
jnp.ndarray |
Upper bound of the prediction interval (if level is provided). |
forecast(self, y: jnp.ndarray, h: int, X: jnp.ndarray | None = None, X_future: jnp.ndarray | None = None, level: list[int | float] | None = None, fitted: bool = False) -> dict
Stateless fit-then-predict on y.
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 containing the forecast.
| Key | Type | Description |
|---|---|---|
"mean" |
jnp.ndarray |
The point forecast. |
"fitted" |
jnp.ndarray |
One-step-ahead fitted values (if fitted=True). |
lower_<level> |
jnp.ndarray |
Lower bound of the prediction interval (if level is provided). |
upper_<level> |
jnp.ndarray |
Upper bound of the prediction interval (if level is provided). |
Raises: NotImplementedError (if X or X_future is not None). |
AutoformerForecaster
chronax.models.autoformer.forecaster · inherits Autoformer
Deprecated config-based constructor; prefer :class:Autoformer.
__init__(self, config: AutoformerConfig, *, max_steps: int = 1000, learning_rate: float = 0.0001, batch_size: int = 32, num_lr_decays: int = 3, val_fraction: float = 0.1, val_check_steps: int = 100, early_stop_patience_steps: int = -1, grad_clip: float = 1.0, weight_decay: float = 0.0, loss: Union[str, LossFn, Callable] = 'mae', seed: int = 1)
Deprecated constructor. Use Autoformer(h=..., input_size=..., random_seed=...) instead.
| Parameter | Type | Default | Description |
|---|---|---|---|
config |
AutoformerConfig |
- | (undocumented) |
max_steps |
int |
1000 |
(undocumented) |
learning_rate |
float |
0.0001 |
(undocumented) |
batch_size |
int |
32 |
(undocumented) |
num_lr_decays |
int |
3 |
(undocumented) |
val_fraction |
float |
0.1 |
(undocumented) |
val_check_steps |
int |
100 |
(undocumented) |
early_stop_patience_steps |
int |
-1 |
(undocumented) |
grad_clip |
float |
1.0 |
(undocumented) |
weight_decay |
float |
0.0 |
(undocumented) |
loss |
Union[str, LossFn, Callable] |
'mae' |
(undocumented) |
seed |
int |
1 |
(undocumented) |