Table of Contents

Class NBEATSModelOptions<T>

Namespace
AiDotNet.Models.Options
Assembly
AiDotNet.dll

Configuration options for the N-BEATS (Neural Basis Expansion Analysis for Time Series) model.

public class NBEATSModelOptions<T> : TimeSeriesRegressionOptions<T>

Type Parameters

T

The numeric type used for calculations (typically double or float).

Inheritance
NBEATSModelOptions<T>
Inherited Members

Remarks

N-BEATS is a deep learning architecture specifically designed for time series forecasting. It uses a hierarchical doubly residual architecture with basis expansion to decompose time series into trend and seasonality components, providing both accurate forecasts and interpretability.

For Beginners: N-BEATS is a modern neural network approach to time series forecasting that can automatically learn patterns from your data without requiring manual feature engineering.

Key concepts:

  • Stacks: Groups of blocks that process the data hierarchically
  • Blocks: Individual processing units within each stack
  • Lookback Window: How many past time steps to consider for predictions
  • Forecast Horizon: How many future time steps to predict
  • Hidden Size: The capacity of the network (larger values can learn more complex patterns)

The model automatically decomposes your time series into interpretable components like trend (long-term direction) and seasonality (repeating patterns).

Constructors

NBEATSModelOptions()

Initializes a new instance of the NBEATSModelOptions<T> class.

public NBEATSModelOptions()

NBEATSModelOptions(NBEATSModelOptions<T>)

Initializes a new instance of the NBEATSModelOptions<T> class by copying from another instance.

public NBEATSModelOptions(NBEATSModelOptions<T> other)

Parameters

other NBEATSModelOptions<T>

The options instance to copy from.

Properties

BatchSize

Gets or sets the batch size for training.

public int BatchSize { get; set; }

Property Value

int

The batch size, defaulting to 32.

Remarks

Determines how many samples are processed together before updating model parameters. Larger batches provide more stable gradients but require more memory.

For Beginners: Instead of updating the model after every single example, we group examples into batches. A batch size of 32 means the model looks at 32 examples before adjusting its parameters. This makes training more efficient and stable.

Epochs

Gets or sets the number of training epochs.

public int Epochs { get; set; }

Property Value

int

The number of epochs, defaulting to 100.

Remarks

An epoch is one complete pass through the entire training dataset. More epochs allow the model to learn better but increase training time.

For Beginners: An epoch is like one complete study session through all your training data. More epochs mean more practice, which usually leads to better learning, but too many can cause the model to memorize the training data instead of learning general patterns (overfitting).

ForecastHorizon

Gets or sets the forecast horizon (number of future time steps to predict).

public int ForecastHorizon { get; set; }

Property Value

int

The forecast horizon, defaulting to 5.

Remarks

Specifies how many time steps ahead the model should forecast. The model is trained to produce forecasts for all steps from 1 to ForecastHorizon simultaneously.

For Beginners: This is how far into the future you want to predict. If forecasting daily sales with a horizon of 5, the model will predict the next 5 days. Longer horizons are generally harder to predict accurately.

HiddenLayerSize

Gets or sets the hidden layer size for the fully connected layers within each block.

public int HiddenLayerSize { get; set; }

Property Value

int

The hidden layer size, defaulting to 256.

Remarks

Controls the capacity of the neural network within each block. Larger values allow the model to learn more complex patterns but increase computational requirements.

For Beginners: This controls how many neurons are in the hidden layers of the network. More neurons mean the model can learn more complex relationships, but require more training data and computation. 256 is a good starting point for most time series problems.

LearningRate

Gets or sets the learning rate for training the model.

public double LearningRate { get; set; }

Property Value

double

The learning rate, defaulting to 0.001.

Remarks

Controls how quickly the model updates its parameters during training. Lower values lead to more stable but slower training, while higher values can speed up training but risk instability.

For Beginners: The learning rate controls how big the steps are when the model is learning. Think of it like learning to ride a bike - small steps (low learning rate) are safer but slower, while big steps (high learning rate) are faster but riskier. 0.001 is a conservative, safe choice.

LookbackWindow

Gets or sets the lookback window size (number of historical time steps used as input).

public int LookbackWindow { get; set; }

Property Value

int

The lookback window size, defaulting to 10.

Remarks

Determines how many past observations are used to predict future values. Should be set based on the expected temporal dependencies in your data.

For Beginners: This is how far back in time the model looks when making predictions. If predicting daily sales, a lookback of 7 means it considers the past week. Larger values allow the model to see more history but require more computation.

NumBlocksPerStack

Gets or sets the number of blocks per stack.

public int NumBlocksPerStack { get; set; }

Property Value

int

The number of blocks per stack, defaulting to 1.

Remarks

Each block performs basis expansion and produces backcast (past) and forecast (future) predictions. Multiple blocks per stack allow for more complex representations.

For Beginners: Blocks are the basic building units within each stack. Each block learns to extract specific patterns from the data. More blocks per stack can improve accuracy but increase training time.

NumHiddenLayers

Gets or sets the number of hidden layers within each block.

public int NumHiddenLayers { get; set; }

Property Value

int

The number of hidden layers, defaulting to 4.

Remarks

Each block uses multiple fully connected layers. More layers allow for deeper feature learning but increase model complexity.

For Beginners: This is how many layers of processing each block has. More layers allow the model to learn more abstract patterns, similar to how deep neural networks can recognize complex features. The default of 4 works well for most applications.

NumStacks

Gets or sets the number of stacks in the N-BEATS architecture.

public int NumStacks { get; set; }

Property Value

int

The number of stacks, defaulting to 30.

Remarks

Each stack consists of multiple blocks that process the time series hierarchically. The original N-BEATS paper uses 30 stacks for generic architecture.

For Beginners: Stacks are layers of processing in the network. More stacks allow the model to learn deeper patterns but require more computation and training data. The default of 30 works well for most applications.

PolynomialDegree

Gets or sets the polynomial degree for trend basis expansion.

public int PolynomialDegree { get; set; }

Property Value

int

The polynomial degree, defaulting to 3.

Remarks

Controls the complexity of polynomial trends the model can represent. Higher degrees allow for more complex trend shapes but may lead to overfitting.

For Beginners: This controls how complex the trend patterns can be. A degree of 3 means the model can represent trends that curve up and down. Higher values allow for more wiggly trends, while lower values are more restricted.

ShareWeightsInStack

Gets or sets whether to share weights across blocks within a stack.

public bool ShareWeightsInStack { get; set; }

Property Value

bool

True to share weights, defaulting to false.

Remarks

When enabled, all blocks within a stack share the same weights, reducing the total number of parameters and acting as a regularization technique.

For Beginners: Weight sharing means that all blocks in a stack use the same learned patterns, which reduces the model size and can help prevent overfitting. However, it also limits the model's flexibility. The default is false, allowing each block to learn independently.

UseInterpretableBasis

Gets or sets whether to use interpretable basis functions (trend and seasonality).

public bool UseInterpretableBasis { get; set; }

Property Value

bool

True to use interpretable basis, defaulting to true.

Remarks

When enabled, the model uses polynomial and Fourier basis functions for interpretability. When disabled, uses generic basis functions that may be more flexible but less interpretable.

For Beginners: Interpretable basis means the model explicitly separates the forecast into trend (long-term direction) and seasonal (repeating patterns) components that you can visualize and understand. This is helpful for explaining the model's predictions. The default is true to provide interpretability.