NSSDNResult.predict#
- NSSDNResult.predict(endog, *, exog=None, time=None)[source]#
One-step conditional predictions over a sample.
Runs the trained network from its learned initial state under teacher forcing and returns, for each \(y_{i+1}\), the emission built from the realized values the alignment allows: through \(y_i\) under both alignments, which under the filtered one is the emission at \(i\),
\[\begin{split}\hat y_{i+1 \mid i} = \begin{cases} \hat y_i, & \text{filtered: the emission after } y_i,\\ \hat y_{i+1}, & \text{predicted: the row that targets } y_{i+1}. \end{cases}\end{split}\]The published holdout protocol is
res.predict(np.concatenate([train, holdout]))[-len(holdout):], the paper’syhat[split - 1 : -1]againsty[split:]: the network conditions on the realized holdout values one step at a time, which is a conditional one-step forecast and not a recursive one.- Parameters:
- Return type:
- Returns:
(len(endog) - 1,)predictions on the original scale, aligned withendog[1:].- Raises:
DimensionError – If
endogis mis-shaped or too short, or ifexogortimeis misaligned or the covariate width differs from the fit’s.NumericalError – If any input contains non-finite values.
SpecificationError – If
timeis not strictly increasing.
Example
On the fitted sample the predictions are the result’s own
fittedvalues:>>> import numpy as np >>> y = np.sin(0.2 * np.arange(120.0)) >>> res = NSSDN(y, k=2, state_dim=8, schedule=(Stage(1e-2, 20),), seed=0).fit() >>> bool(np.allclose(res.predict(y), res.fittedvalues)) True