MLP
chronax.models.mlp_model.MLP ยท inherits BaseForecaster
MLP: Multi Layer Perceptron (flax.nnx port of neuralforecast.MLP). The simplest neural forecaster: the scaled insample window (plus any future-known exogenous inputs, flattened) feeds num_layers fully connected ReLU layers and a raw linear head that emits all h horizon steps at once โ no recurrence, no attention. fit accepts a single series (T,) or an N-series panel (T, n_series); a 2-D fit cross-learns one global network over all columns (channel-independent โ each column is forecast from its own tail context) and predictions follow the input rank. Future-known exogenous inputs are supported (uses_exog = True; shared across columns on a 2-D fit); historical and static exog are not modeled. Point ("mae"/"mse"/"huber"), multi-quantile (MultiQuantileLoss), or Gaussian-mixture (GMM) losses; with a GMM head the model is a probabilistic forecaster whose intervals come from seeded Monte-Carlo samples of the predictive mixture in original units. float32 throughout.
Attributes:
* uses_exog: True
* alias: str
* conformal_params: ConformalIntervals | None
* model_: MLPNet | None
__init__(self, h, input_size=-1, num_layers=2, hidden_size=1024, max_steps=1000, learning_rate=1e-3, windows_batch_size=1024, scaler_type='identity', loss='mae', quantile_sort=True, random_seed=1, alias='MLP')
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
- | - | (undocumented) |
input_size |
- | -1 |
If less than 1, defaults to 3 * h. |
num_layers |
- | 2 |
(undocumented) |
hidden_size |
- | 1024 |
(undocumented) |
max_steps |
- | 1000 |
(undocumented) |
learning_rate |
- | 1e-3 |
(undocumented) |
windows_batch_size |
- | 1024 |
(undocumented) |
scaler_type |
- | "identity" |
(undocumented) |
loss |
- | "mae" |
(undocumented) |
quantile_sort |
- | True |
(undocumented) |
random_seed |
- | 1 |
(undocumented) |
alias |
- | "MLP" |
(undocumented) |
fit(self, y, X=None, *, futr_exog=None) -> Self
Trains the MLP model using pooled windows from y. Supports univariate or multi-series input (y). If y is multi-series, one global network is trained across all series.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Time series data, shape (T,) or (T, n_series). Must be long enough to form at least one window (T >= input_size + 1). |
X |
None |
None |
Not supported. Raises NotImplementedError. |
futr_exog |
jnp.ndarray |
None |
Future-known exogenous inputs, aligned with y. Shape (T, F). |
Returns: Self (the fitted forecaster; sets self.model_).
Raises: NotImplementedError, ValueError.
predict(self, h, X=None, *, futr_exog=None, level=None) -> dict
Generates forecasts for horizon h using the fitted model and the context stored during fit.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon. Must be less than or equal to the h used during initialization. |
X |
None |
None |
(undocumented) |
futr_exog |
jnp.ndarray |
None |
Future-known exogenous inputs for the forecast horizon, shape (h, F). Required if the model was fit with futr_exog. |
level |
list[int] |
None |
Confidence levels (e.g., [80, 95]) for prediction intervals. |
Returns: dict.
Keys include:
* "mean": jnp.ndarray (Point forecast. Shape (h,) for 1-D fit, (h, n_series) for 2-D fit. Derived from median for quantile loss, analytic mean for distribution loss, or raw output for point loss).
* "lo-L": jnp.ndarray (Lower bound of the L% prediction interval, present if level is provided).
* "hi-L": jnp.ndarray (Upper bound of the L% prediction interval, present if level is provided).
forecast(self, y, h, X=None, X_future=None, *, futr_exog=None, level=None, fitted=False) -> dict
Stateless fit-then-predict. X is unsupported (MLP models future-known exog only); X_future = future-known exog for the horizon (h, F); futr_exog = its history (T, F).
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Time series data used for fitting. |
h |
int |
- | Forecast horizon. |
X |
None |
None |
Not supported. Passed to fit. |
X_future |
jnp.ndarray |
None |
Future-known exogenous inputs for the forecast horizon, passed as futr_exog to predict. Shape (h, F). |
futr_exog |
jnp.ndarray |
None |
Historical future-known exogenous inputs, passed as futr_exog to fit. Shape (T, F). |
level |
list[int] |
None |
Confidence levels for prediction intervals. |
fitted |
bool |
False |
If True, computes and returns fitted values (one-step ahead predictions on the training set). Only supported for 1-D fits without temporal exog. |
Returns: dict. Same keys as predict. If fitted=True, includes:
* "fitted": jnp.ndarray (Fitted values).
conformity_scores(self, y, X=None) -> jnp.ndarray
Calculates conformity scores for the provided series y.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Time series data. Must be 1-D. |
X |
None |
None |
(undocumented) |
Returns: jnp.ndarray (Conformity scores).
Raises: ValueError.