Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:Online ml River SNARIMAX Forecasting

From Leeroopedia


Knowledge Sources Domains Last Updated
River River Docs Online Learning for Time Series Prediction Online Machine Learning, Time Series Forecasting, ARIMA 2026-02-08 16:00 GMT

Overview

Online implementation of the SNARIMAX model (Seasonal Non-linear AutoRegressive Integrated Moving Average with eXogenous inputs) for streaming time series forecasting.

Description

SNARIMAX is a comprehensive online time series forecasting model that generalizes the classical ARIMA family of models into a single interface trainable with streaming data. The name encodes each component:

  • S (Seasonal): Captures repeating patterns at a specified seasonal period m
  • N (Non-linear): Any online regression model can serve as the internal learner, not just linear regression
  • AR (AutoRegressive): Past target values (lags) are used as features
  • I (Integrated): Differencing is applied to achieve stationarity; integration (the inverse) is applied at forecast time
  • MA (Moving Average): Past forecast errors are used as features
  • X (eXogenous): External features can be incorporated alongside the autoregressive and moving average components

By toggling the order parameters (p, d, q, sp, sd, sq), classical models such as AR, MA, ARMA, ARIMA, and SARIMA emerge as special parametrizations of SNARIMAX.

Usage

Use SNARIMAX when:

  • You need to forecast a time series that may exhibit trend, seasonality, or both
  • Data arrives sequentially and the model must be updated incrementally
  • You want the flexibility to plug in any online regressor (e.g., linear regression, decision trees)
  • Exogenous variables (external features) are available and should be incorporated into predictions
  • You need a model that generalizes classical ARIMA to the online setting

Theoretical Basis

The SNARIMAX model extends the Box-Jenkins ARIMA methodology to an online learning framework. The model is composed of the following components:

Autoregressive Component AR(p)

The AR component uses p lagged values of the (differenced) target series as features:

AR features: y_{t-1}, y_{t-2}, ..., y_{t-p}

Integrated Component I(d)

Differencing of order d transforms the series to achieve stationarity. For d = 1:

y'_t = y_t - y_{t-1}

Higher-order differencing is applied recursively. At forecast time, the differencing is undone (integrated) to recover predictions in the original scale.

Moving Average Component MA(q)

The MA component uses q past forecast errors as features:

MA features: e_{t-1}, e_{t-2}, ..., e_{t-q}
where e_t = y_t - hat{y}_t

Seasonal Components S-AR(sp), S-I(sd), S-MA(sq)

Seasonal counterparts operate at multiples of the seasonal period m:

Seasonal AR features: y_{t-m}, y_{t-2m}, ..., y_{t-sp*m}
Seasonal MA features: e_{t-m}, e_{t-2m}, ..., e_{t-sq*m}
Seasonal differencing: (1 - B^m)^{sd} y_t

Online Learning Formulation

At each time step t:

  1. Construct features: Gather AR lags, seasonal AR lags, MA errors, and seasonal MA errors, plus any exogenous features
  2. Difference: Apply the combined differencer (non-seasonal times seasonal) to obtain y'_t
  3. Predict: The internal regressor predicts hat{y'}_t from the feature vector
  4. Update error buffer: Compute e_t = y'_t - hat{y'}_t and store in the error deque
  5. Learn: The regressor updates its weights via regressor.learn_one(features, y'_t)

The default regressor is StandardScaler | LinearRegression which uses SGD, but any River-compatible regressor can be substituted.

Forecasting

The forecast(horizon) method uses a recursive strategy:

  1. Predict the next differenced value using current lags and errors
  2. Undifferentiate to recover the original scale
  3. Feed the prediction back as a lag for subsequent steps
  4. Assume zero error for future steps (errors are set to 0)

References

  • Box, G.E.P., Jenkins, G.M., Reinsel, G.C. — Time Series Analysis: Forecasting and Control
  • Anava, O., Hazan, E., Mannor, S. and Shamir, O. (2013) — Online Learning for Time Series Prediction (COLT 2013)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment