Time Series Forecasting Algorithm
The Time Series Forecasting algorithm creates predictive models that generate forecasts for future values of a time‑dependent variable. It is part of Microsoft SQL Server Analysis Services (SSAS) Data Mining.
When to Use
- Predicting sales, demand, or inventory levels over time.
- Analyzing seasonality, trends, and cyclic patterns.
- Scenarios where the target column is numeric and varies with time.
How It Works
The algorithm builds a model by applying the ARIMA (Auto‑Regressive Integrated Moving Average) technique combined with exponential smoothing. It automatically detects:
- Trend components (increasing/decreasing).
- Seasonal cycles (daily, weekly, monthly).
- Irregular fluctuations.
Overview
Parameters
Example
The model stores the historical values and uses them to forecast future points. You can request the Predicted column in a mining query to retrieve the forecast.
Key Parameters
| Parameter | Description |
|---|---|
PredictionLength | Number of future periods the model should forecast. |
ConfidenceLevel | Confidence interval (0‑100) for prediction bounds. |
Seasonality | Length of the seasonal cycle (e.g., 12 for monthly data). |
Horizon | How many steps ahead to train the model. |
Creating a Time Series Model
CREATE MINING MODEL [dbo].[SalesForecast]
FROM [dbo].[SalesData]
WITH (TYPE = TIME_SERIES,
DATA_SOURCE = (TABLE = [dbo].[SalesData]),
TARGET_COLUMN = [SalesAmount],
TIME_ID_COLUMN = [SaleDate],
TIME_ORDER_COLUMN = [SaleDate],
PREDICTION_LENGTH = 12,
CONFIDENCE_LEVEL = 95);
Querying the Forecast
SELECT [SalesAmount], [Predicted]
FROM OpenQuery([YourSSAS], 'SELECT * FROM [SalesForecast]')
WHERE [SaleDate] >= DATEADD(month, -24, GETDATE());
Best Practices
- Ensure the
TIME_ID_COLUMNis of a date/time type and has no gaps. - Remove outliers or use a robust preprocessing step.
- Experiment with different
Seasonalityvalues to capture actual cycles.