RNNTestForecasting
The RNNTestForecasting object provides a suite of time–series utilities and forecasting experiments using Autograd–based recurrent neural networks. It includes:
- lagged–window matrix builders (
buildMatrix4TS,buildMatrix4TSX) - batch construction utilities for sequence models (
makeBatches) - demonstration tests for RNN and GRU models on: • synthetic sequences • COVID–19 new-deaths data • ILI (Influenza-Like Illness) data
- chronological train/test splits
- rolling / walk–forward validation These tests verify correctness of data pipelines, shape handling, training loops, scaling transformations, and forecasting performance.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RNNTestForecasting.type
Members list
Value members
Concrete methods
Build lagged feature matrix and horizon-ahead target matrix for univariate time–series forecasting.
Build lagged feature matrix and horizon-ahead target matrix for univariate time–series forecasting.
Value parameters
- backcast
-
if
true, constructs backward windows for reconstruction tests - hh
-
forecast horizon (steps ahead)
- lags
-
number of past time steps used as model input
- y
-
the raw input series
Attributes
- Returns
-
a tuple
(x, yy)where: -xis the lagged matrix (windows × features) -yyis the horizon-matrix aligned withx
Build lagged feature matrix for time-series with exogenous inputs.
Build lagged feature matrix for time-series with exogenous inputs.
Value parameters
- backcast
-
whether to generate backward windows
- hh
-
forecast horizon
- isTest
-
if
true, skip alignment trimming - lags
-
number of lagged steps to include
- xe
-
exogenous variables (matrix)
- y
-
endogenous (target) series
Attributes
- Returns
-
(x_trim, yy_trim)aligned lagged feature + horizon matrices
Forecast COVID-19 new deaths using a single-layer GRU.
Forecast COVID-19 new deaths using a single-layer GRU.
Run:
runMain scalation.modeling.autograd.gruCovidTest
Attributes
GRU forecasting with chronological split on either COVID or ILI datasets. Uses:
GRU forecasting with chronological split on either COVID or ILI datasets. Uses:
- log transform + scaling
- validation-based LR scheduling (ReduceLROnPlateau)
- truncated backprop (TBPTT) option in GRU.forward
- full diagnostics and plots for predictions Run:
runMain scalation.modeling.autograd.gruCovidTest2
Attributes
GRU toy example trained on a noisy sine wave. Demonstrates:
GRU toy example trained on a noisy sine wave. Demonstrates:
- GRUCell correctness in forecasting a smooth periodic signal
- batching, training, clipping, plotting Run:
runMain scalation.modeling.autograd.gruSineTest
Attributes
Convert lagged matrices into mini-batches suitable for RNN/GRU models. Splits the dataset into batches, converts each window into an ordered input sequence (X_t0, X_t1, ..., X_tn) and attaches the corresponding target tensor for supervised sequence forecasting.
Convert lagged matrices into mini-batches suitable for RNN/GRU models. Splits the dataset into batches, converts each window into an ordered input sequence (X_t0, X_t1, ..., X_tn) and attaches the corresponding target tensor for supervised sequence forecasting.
Value parameters
- batchSize
-
batch size for training
- nFeatures
-
number of features at each time step (default = 1)
- xSeq
-
full lagged input matrix
- ySeq
-
horizon target matrix
Attributes
- Returns
-
an indexed sequence of
(inputSeq, target)batch pairs
Forecast COVID-19 weekly new deaths using a single-layer RNN. Pipeline: 1. load + scale the dataset 2. convert into lagged windows 3. batch for RNN input 4. train with Adam + StepLR 5. compute QoF metrics (R², SMAPE, MAE, RMSE) 6. plot predictions & training loss Run:
Forecast COVID-19 weekly new deaths using a single-layer RNN. Pipeline: 1. load + scale the dataset 2. convert into lagged windows 3. batch for RNN input 4. train with Adam + StepLR 5. compute QoF metrics (R², SMAPE, MAE, RMSE) 6. plot predictions & training loss Run:
runMain scalation.modeling.autograd.rnnCovidTest
Attributes
Chronological (or Temporal) train/test split forecasting using RNN. Features:
Chronological (or Temporal) train/test split forecasting using RNN. Features:
- Temporal holdout (e.g., first 80% train, remaining test)
- adaptive learning rate via
ReduceLROnPlateau - early stopping
- rescaling predictions back to original space
- complete QoF metrics for train & test Run:
runMain scalation.modeling.autograd.rnnCovidTest1
Attributes
Chronological split forecasting with:
Chronological split forecasting with:
- log → scale → train → unscale → exp transform pipeline
- validation set carved out of training windows
- ReduceLROnPlateau for LR scheduling
- early stopping based on validation loss Supports both COVID and ILI depending on loaded dataset. Run:
runMain scalation.modeling.autograd.rnnCovidTest2
Attributes
Walk-forward (rolling) validation: 1-step-ahead forecasting. Each fold:
Walk-forward (rolling) validation: 1-step-ahead forecasting. Each fold:
- trains (or reuses) the RNN on all available data up to time t
- predicts the next point t+1
- logs QoF metrics Supports growing or rolling windows and periodic retraining. Run:
runMain scalation.modeling.autograd.rnnCovidTestRollVal
Attributes
Forecast ILI (Influenza-Like Illness) incidence using a single-layer RNN. Similar to the COVID test but uses a longer lag window (21 weeks). Includes scaling, batching, training with Adam + StepLR, diagnostics and plots. Run:
Forecast ILI (Influenza-Like Illness) incidence using a single-layer RNN. Similar to the COVID test but uses a longer lag window (21 weeks). Includes scaling, batching, training with Adam + StepLR, diagnostics and plots. Run:
runMain scalation.modeling.autograd.rnnILITest
Attributes
Test utility functions used for RNN forecasting:
Test utility functions used for RNN forecasting:
- lag construction
- horizon matrix construction
- batch formatting into proper RNN tensors Demonstrates window creation for a simple synthetic series. Run using:
runMain scalation.modeling.autograd.rnnUtilityTest