Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Online ml River Time Series Base Interface

From Leeroopedia


Knowledge Sources
Domains Online_Learning, Time_Series_Forecasting
Last Updated 2026-02-08 18:00 GMT

Overview

Time series base interfaces define the abstract contract that online time series forecasting models must satisfy. A base interface specifies the methods for learning from a new observation, making one-step-ahead or multi-step-ahead forecasts, and optionally providing prediction intervals -- all in an incremental fashion.

Establishing a uniform interface is critical in streaming systems because it enables interchangeable forecasters within pipelines, ensemble methods, and evaluation frameworks without coupling to any specific algorithm.

Theoretical Basis

Online Forecasting Protocol

An online time series forecaster processes observations one at a time in chronological order. The standard protocol is:

for t = 1, 2, 3, ...:
    y_hat = model.forecast(horizon=1)   # predict before seeing y_t
    model.learn_one(y_t)                 # update with the true value
    error = loss(y_hat, y_t)             # evaluate

This prequential (predictive sequential) evaluation ensures that the model is always tested on data it has not yet seen.

Key Interface Methods

  • learn_one(y): Update the model with a single new observation y_t. The model must update in O(1) or O(k) time where k is a model-specific constant (e.g., number of lags).
  • forecast(horizon): Produce predictions for the next h time steps. For h > 1, this may require recursive forecasting (feeding predictions back as inputs) or direct multi-step estimation.

Exogenous Variables

Many forecasting problems include external features x_t (e.g., weather, calendar events) alongside the target series y_t. The interface supports this via:

model.learn_one(y_t, x_t)
y_hat = model.forecast(horizon=1, x_future)

Stationarity and Differencing

Classical time series theory assumes stationarity (constant mean and variance). Non-stationary series are typically differenced before modeling. In the online setting, differencing is applied as a stream transformation, and the forecaster operates on the transformed series.

Design Principles

  • Separation of concerns: The interface separates learning, prediction, and evaluation into distinct steps.
  • Composability: Base interfaces enable building composite models (e.g., ensembles, pipelines) from simpler forecasters.
  • Minimal state: The forecaster maintains only the state necessary for its algorithm (e.g., recent lags, running statistics).

Related Pages

Page Connections

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