ETSformer<T>
Models & Types · AiDotNet.Finance.Forecasting.Transformers
ETSformer: Exponential Smoothing Transformer for time series forecasting.
Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → ForecastingModelBase<T> → ETSformer<T>
For Beginners
ETSformer is like having a smart forecaster that can:
- See the Level: The overall value of the time series (like average price level)
- See the Trend: Whether values are going up or down over time
- See Seasonality: Repeating patterns (like daily or weekly cycles)
Unlike black-box models, ETSformer lets you inspect each component to understand WHY it makes certain predictions. This is valuable in finance where explainability matters.
How It Works
ETSformer combines classical exponential smoothing (ETS) methods with transformer attention mechanisms to create an interpretable time series forecasting model. It explicitly models level, trend, and seasonal components.
Key Innovation: The exponential smoothing attention mechanism applies learnable decay factors, giving more weight to recent observations while still considering historical patterns through the transformer architecture.
Reference: Woo et al., “ETSformer: Exponential Smoothing Transformers for
Time-series Forecasting”, 2022. https://arxiv.org/abs/2202.01381
Example
// Create an ETSformer for interpretable time series forecasting
// Combines exponential smoothing with transformer attention for level/trend/seasonal decomposition
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputHeight: 96, inputWidth: 7, inputDepth: 1, outputSize: 24);
// Training mode with exponential smoothing attention
var model = new ETSformer<double>(architecture);
// ONNX inference mode with pre-trained model
var onnxModel = new ETSformer<double>(architecture, "etsformer_electricity.onnx");
Constructors
| Constructor | Summary |
|---|---|
ETSformer(NeuralNetworkArchitecture<T> architecture, ETSformerOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Creates an ETSformer model in native C# mode for training and inference. |
ETSformer(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, ETSformerOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Creates an ETSformer model in ONNX inference mode using a pre-trained model. |
Properties
| Property | Summary |
|---|---|
bool IsChannelIndependent { get; } |
|
bool SupportsTraining { get; } |
Gets whether this model supports training (native mode only). |
bool UseNativeMode { get; } |
|
int NumFeatures { get; } |
|
int PatchSize { get; } |
|
int PredictionHorizon { get; } |
|
int SequenceLength { get; } |
|
int Stride { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> Evaluate(Tensor<T> predictions, Tensor<T> actuals) |
|
Dictionary<string, T> GetFinancialMetrics() |
|
ModelMetadata<T> GetModelMetadata() |
Gets metadata describing the model. |
Tensor<T> ApplyInstanceNormalization(Tensor<T> input) |
|
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps) |