NSSDN#
- class cultivars.experimental.spectral.NSSDN(endog, *, exog=None, time=None, k=16, state_dim=128, alignment='filtered', transition='gru', positive_frequency=True, ordered_frequency=False, gating=True, objective='mse', delta=_HUBER_DELTA, penalties=None, schedule=None, scaling='minmax', seed=None, device='cpu')[source]#
Non-Stationary Spectral Decomposition Network specification.
The immutable statement of the model, validated at construction and estimated by
fit(). The defaults are the configuration of the IEEE-ORSS DGS10 experiments: sixteen components, a 128-dimensional GRU state, positive frequencies, gating, the filtered alignment, mean squared error on a min-max scaled series, and the two-stage Adam schedule with amplitude and frequency drift penalties. With no covariates that network has 58,849 trainable parameters, the count of the published run.- Parameters:
endog (
ArrayLike) – The series, one-dimensional, at least three observations.exog (
ArrayLike|None) – Optional(n, p)covariates known at eacht, used as given (no scaling). A fit with covariates needs them again at forecast time.time (
ArrayLike|None) – Optional strictly increasing grid; defaults to0 .. n - 1. Irregular spacing enters the phase recursion and, under the time-aware transition, the dynamics.k (
int) – Number of sinusoidal components.state_dim (
int) – Latent dimensiond.alignment (
str) –"filtered"(the published run: the emission attconditions ony_t) or"predicted"(it conditions ony_{t-1}, so the network trains as a one-step forecaster).transition (
str) –"gru"or"timeaware".positive_frequency (
bool) – Softplus the frequency head so phase always advances.ordered_frequency (
bool) – Parameterize frequencies as cumulative positive gaps inside the Nyquist band, soomega_{t,1} < ... < omega_{t,K}at everytand the components are identified without permutation. Off by default to reproduce the published run.gating (
bool) – Add the sigmoid gate head.objective (
str) –"mse"or"huber".delta (
float) – Huber threshold on the scaled residual.penalties (
Penalties|None) –Penaltiesfor stages that carry none.schedule (
tuple[Stage,...] |None) – Tuple ofStage; the published two stages by default.scaling (
str) –"minmax"or"none".seed (
int|None) – Initialization seed;Noneleaves the fit unreproducible.device (
str) – Torch device string.
- Raises:
SpecificationError – If any option is outside its admissible set.
DimensionError – If the data are mis-shaped or misaligned.
NumericalError – If the data contain non-finite values, or training diverges.
Note
Training is one full-sequence gradient per step through the whole sample, so cost scales with
ntimes the schedule length; the published run is 3,000 steps over 9,186 daily observations. Under the GRU transition the teacher-forced pass is a single recurrent call rather than a Python loop.See also
NSSDNResult– whatfit()returns.Stage,Penalties– the schedule records.
Example
>>> import numpy as np >>> y = np.sin(0.3 * np.arange(200.0)) + 0.01 * np.arange(200.0) >>> model = NSSDN(y, k=2, state_dim=8, schedule=(Stage(1e-2, 30),), seed=0) >>> model.k, model.alignment, model.transition, len(model.schedule) (2, 'filtered', 'gru', 1) >>> NSSDN(y, transition="lstm") Traceback (most recent call last): ... ns_sdn.exceptions.SpecificationError: transition must be one of 'gru', 'timeaware'; ...
Attributes#
What the emission at |
|
The torch device. |
|
The validated series. |
|
The validated covariates, or |
|
Number of covariate columns. |
|
Whether the gate head is present. |
|
Number of components. |
|
Observations in the sample, before the one-step shift. |
|
The prediction loss. |
|
Whether frequencies are strictly increasing in |
|
Model-level penalty weights. |
|
Whether frequencies are constrained positive. |
|
The scaling choice. |
|
The training stages. |
|
The initialization seed. |
|
Latent dimension. |
|
The time grid. |
|
The transition kind. |
Methods#
|
Train the network on the sample and return the fitted result. |