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.

DeepNPTS

chronax.models.deepnpts_model.DeepNPTS · inherits BaseForecaster

Univariate DeepNPTS forecaster (JAX/Flax-NNX port of neuralforecast.DeepNPTS). Deep Non-Parametric Time Series forecaster (Rangapuram, Gasthaus, Stella, Flunkert, Salinas, Wang & Januschowski, 2023). A small MLP reads the lookback window and emits, per horizon step, a softmax weight over each window position; the forecast is the weighted sum of the raw in-sample values, i.e. a learned non-parametric resample of the context. For the univariate, no-exogenous case the MLP input dimension is input_size. NF default scaler_type="identity" is mirrored (trained in raw scale) with Optax adam and a pluggable point loss. float32 throughout.

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: * uses_exog: False * alias: str * conformal_params: ConformalIntervals | None * model_: DeepNPTSNet | None

__init__(self, h, input_size=32, hidden_size=32, n_layers=2, dropout=0.1, batch_norm=False, use_boxcox=False, max_steps=1000, learning_rate=0.001, windows_batch_size=1024, random_seed=1, alias='DeepNPTS', loss='mae')

Initialize a DeepNPTS forecaster. Stores hyperparameters; the network is built lazily at fit time. Defaults match neuralforecast.DeepNPTS for the univariate case (hidden_size=32, n_layers=2, dropout=0.1, max_steps=1000, learning_rate=1e-3, windows_batch_size=1024, scaler_type="identity"), with one documented override: batch_norm defaults to False (NF defaults True). input_size=-1 resolves to 3 * h. loss is a registry name ("mae"/"mse"/"huber") or a callable; learning_rate is a scalar or an optax.ScalarOrSchedule. If the fitted estimator will be pickled, any callable passed for loss/learning_rate must itself be picklable.

batch_norm (default False) applies Batch Normalization after each dense layer, matching NF's default architecture when enabled. It is left off by default because BatchNorm carries non-parameter running statistics that add state complexity to training, inference, and pickling; when enabled it uses momentum=0.9 (equivalent to torch's 0.1) and eps=1e-5.

use_boxcox (default False) applies a variance-stabilizing Box-Cox transform before modelling and inverts it on the forecast, mirroring :class:chronax.models.TBATS. It requires strictly positive values. Left off, the model is a faithful port of neuralforecast.DeepNPTS.

Parameter Type Default Description
h int - (undocumented)
input_size int 32 If < 1, resolves to 3 * h.
hidden_size int 32 (undocumented)
n_layers int 2 (undocumented)
dropout float 0.1 (undocumented)
batch_norm bool False Applies Batch Normalization after each dense layer.
use_boxcox bool False Applies a variance-stabilizing Box-Cox transform before modelling and inverts it on the forecast.
max_steps int 1000 (undocumented)
learning_rate Union[float, Callable[[int], float]] 1e-3 A scalar or an optax.ScalarOrSchedule.
windows_batch_size int 1024 (undocumented)
random_seed int 1 (undocumented)
alias str "DeepNPTS" (undocumented)
loss Union[str, LossFn] "mae" A registry name ("mae"/"mse"/"huber") or a callable.

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

Fit the network on a 1-D series of length >= input_size + h.

Parameter Type Default Description
y jnp.ndarray - (undocumented)
X jnp.ndarray | None None (undocumented)

Returns: Self (the fitted forecaster; sets self.model_). Raises: NotImplementedError, ValueError

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

Forecast h steps (1 <= h <= self.h) from the fitted context.

Parameter Type Default Description
h int - (undocumented)
X jnp.ndarray | None None (undocumented)
level list[int | float] | None None (undocumented)

Returns: dict. Keys: {"mean": jnp.ndarray}. If level is provided, includes prediction interval keys (e.g., {"lower_level": jnp.ndarray, "upper_level": jnp.ndarray}).

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

Stateless fit-then-predict on y. Optionally add "fitted".

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. Keys: {"mean": jnp.ndarray}. If level is provided, includes prediction interval keys. If fitted=True, includes "fitted": jnp.ndarray.