DLinear
chronax.models.DLinear · inherits BaseForecaster
Univariate DLinear forecaster (JAX/Flax-NNX port of neuralforecast.DLinear). Decomposes each input window into trend (edge-padded moving average of size moving_avg_window) and seasonal (residual), applies one linear head to each, and sums (Zeng et al., 2023). Defaults match neuralforecast 3.1.7 (moving_avg_window=25, max_steps=5000, learning_rate=1e-4, identity scaler, MAE loss) so the benchmark harness compares both libraries at native settings.
Maintenance status: Active univariate forecaster. Integrates with the BaseForecaster interface, including conformal prediction intervals via predict(level=...), pickle round-trip, and forecast(fitted=True).
Attributes
| Attribute | Value | Description |
|---|---|---|
uses_exog |
False |
Indicates that this model does not support exogenous variables. |
alias |
"DLinear" |
The default alias for the model instance. |
__init__(self, h: int, input_size: int = -1, moving_avg_window: int = 25, max_steps: int = 5000, learning_rate: Union[float, Callable[[int], float]] = 1e-4, windows_batch_size: int = 1024, loss: Union[str, LossFn] = 'mae', scaler: Union[str, Scaler] = 'identity', random_seed: int = 1, alias: str = 'DLinear')
Initializes the DLinear forecaster configuration.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon. |
input_size |
int |
-1 |
If < 1 (default), expands to 3*h. |
moving_avg_window |
int |
25 |
Size of the edge-padded moving average used for trend decomposition. Must be odd and positive. |
max_steps |
int |
5000 |
(undocumented) |
learning_rate |
Union[float, Callable[[int], float]] |
1e-4 |
(undocumented) |
windows_batch_size |
int |
1024 |
(undocumented) |
loss |
Union[str, LossFn] |
"mae" |
(undocumented) |
scaler |
Union[str, Scaler] |
"identity" |
"identity" (default, matches neuralforecast) or "robust". |
random_seed |
int |
1 |
(undocumented) |
alias |
str |
"DLinear" |
(undocumented) |
fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None) -> Self
Fit on a 1-D series.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | 1-D series to fit. |
X |
jnp.ndarray \| None |
None |
Exogenous variables (not supported). |
Returns: Self (the fitted forecaster; sets self.model_).
Raises:
* NotImplementedError: on exog.
* ValueError: if y is not 1-D or shorter than input_size + h.
* RuntimeError: on divergence.
predict(self, h: int, X: jnp.ndarray | None = None, level: list[int | float] | None = None) -> dict
Forecast h steps ($1 \le h \le \text{self.h}$). level triggers the inherited conformal path.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon (must be $1 \le h \le \text{self.h}$). |
X |
jnp.ndarray \| None |
None |
(undocumented) |
level |
list[int \| float] \| None |
None |
Prediction interval levels (triggers conformal prediction). |
Returns: dict
Keys: {"mean": jnp.ndarray}. If level is provided, includes keys for prediction intervals (e.g., lower_XX, upper_XX).
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.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
h |
int |
- | (undocumented) |
X |
jnp.ndarray \| None |
None |
Exogenous variables (not supported). |
X_future |
jnp.ndarray \| None |
None |
Exogenous variables (not supported). |
level |
list[int \| float] \| None |
None |
(undocumented) |
fitted |
bool |
False |
If True, adds one-step-ahead fitted values to the result. |
Returns: dict
Keys: {"mean": jnp.ndarray}. Optionally includes prediction intervals and {"fitted": jnp.ndarray} if fitted=True.