ExponentialSmoothingModel<T>
Models & Types · AiDotNet.TimeSeries
Represents a model that implements exponential smoothing for time series forecasting.
Inheritance: TimeSeriesModelBase<T> → ExponentialSmoothingModel<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
Exponential smoothing helps predict future values based on past data.
Think of it like predicting tomorrow’s weather:
- Recent weather (yesterday, today) is more important than weather from weeks ago
- You can identify trends (getting warmer over time)
- You can account for seasons (summer is usually warmer than winter)
For example, if you’re forecasting daily sales:
- Simple smoothing: Uses a weighted average of past values, giving more weight to recent sales
- Double smoothing: Also captures if sales are trending up or down
- Triple smoothing: Adds seasonal patterns (e.g., higher sales on weekends)
Exponential smoothing is called “exponential” because the weight given to older data decreases exponentially as the data gets older.
How It Works
Exponential smoothing is a time series forecasting method that assigns exponentially decreasing weights to past observations, giving more importance to recent data while still considering older observations. This model supports simple, double (with trend), and triple (with trend and seasonality) exponential smoothing.
Example
using AiDotNet;
using AiDotNet.Data.Loaders;
using AiDotNet.TimeSeries;
using AiDotNet.Tensors.LinearAlgebra;
double[] series =
{
120, 135, 148, 160, 155, 170, 180, 195, 210, 198, 220, 235,
140, 155, 165, 178, 172, 190, 200, 215, 230, 218, 245, 260
};
var x = new Matrix<double>(series.Length, 1);
for (int i = 0; i < series.Length; i++) x[i, 0] = i;
var result = await new AiModelBuilder<double, Matrix<double>, Vector<double>>()
.ConfigureModel(new ExponentialSmoothingModel<double>())
.ConfigureDataLoader(DataLoaders.FromMatrixVector(x, new Vector<double>(series)))
.BuildAsync();
var forecast = result.Predict(new Matrix<double>(6, 1));
Console.WriteLine($"ExponentialSmoothingModel: forecast {forecast.Length} steps.");
Constructors
| Constructor | Summary |
|---|---|
ExponentialSmoothingModel() |
Initializes a new instance with default settings. |
ExponentialSmoothingModel(ExponentialSmoothingOptions<T> options) |
Initializes a new instance of the ExponentialSmoothingModel class with the specified options. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> EvaluateModel(Matrix<T> xTest, Vector<T> yTest) |
Evaluates the model’s performance on test data. |
ModelMetadata<T> GetModelMetadata() |
Returns metadata about the model, including its type, parameters, and configuration. |
T PredictSingle(Vector<T> input) |
Predicts a single value based on the input features vector. |
Vector<T> Forecast(Vector<T> history, int steps) |
Forecasts future values by first replaying smoothing updates over the provided history to align state, then projecting forward for the requested number of steps. |
Vector<T> Predict(Matrix<T> input) |
Generates predictions for the given input data. |
void Reset() |
Deserializes the model’s core parameters from a binary reader. |