ARIMAModel<T>
Models & Types · AiDotNet.TimeSeries
Implements an ARIMA (AutoRegressive Integrated Moving Average) model for time series forecasting.
Inheritance: TimeSeriesModelBase<T> → ARIMAModel<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
ARIMA is a popular technique for analyzing and forecasting time series data (data collected over time, like stock prices, temperature readings, or monthly sales figures).
How It Works
ARIMA models are widely used for time series forecasting. The model combines three components:
- AR (AutoRegressive): Uses the dependent relationship between an observation and a number of lagged observations
- I (Integrated): Uses differencing of observations to make the time series stationary
- MA (Moving Average): Uses the dependency between an observation and residual errors from a moving average model
Think of ARIMA as combining three different approaches:
The model has three key parameters (p, d, q):
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 ARIMAModel<double>())
.ConfigureDataLoader(DataLoaders.FromMatrixVector(x, new Vector<double>(series)))
.BuildAsync();
var forecast = result.Predict(new Matrix<double>(6, 1));
Console.WriteLine($"ARIMAModel: forecast {forecast.Length} steps.");
Constructors
| Constructor | Summary |
|---|---|
ARIMAModel(ARIMAOptions<T> options) |
Creates a new ARIMA model 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. |
List<ValueTuple<int, T, T, T>> DetectAnomaliesDetailed(Vector<T> timeSeries) |
Detects anomalies and returns detailed information about each detected anomaly. |
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the model, including its type, parameters, and configuration. |
T GetAnomalyThreshold() |
Gets the current anomaly detection threshold. |
T PredictSingle(Vector<T> input) |
Predicts a single value based on the input vector. |
Vector<T> ComputeAnomalyScores(Vector<T> timeSeries) |
Computes anomaly scores for each point in a time series. |
Vector<T> Forecast(Vector<T> history, int steps) |
Forecasts future values using the trained ARIMA model, properly handling differencing. |
Vector<T> Predict(Matrix<T> input) |
Makes predictions using the trained ARIMA model. |
bool[] DetectAnomalies(Vector<T> timeSeries) |
Detects anomalies in a time series by comparing predictions to actual values. |
void SetAnomalyThreshold(T threshold) |
Sets a custom anomaly detection threshold. |