The ML.FORECAST function

This document describes the ML.FORECAST function, which you can use to forecast a time series based on a trained ARIMA_PLUS or ARIMA_PLUS_XREG model.

Syntax

# ARIMA_PLUS models:
ML.FORECAST(
  MODEL `project_id.dataset.model`
    STRUCT(
      [, horizon AS horizon]
      [, confidence_level AS confidence_level]))

# ARIMA_PLUS_XREG model:
ML.FORECAST(
  MODEL `project_id.dataset.model`
    { TABLE `project_id.dataset.table` | (query_statement) }
    STRUCT(horizon AS horizon, confidence_level AS confidence_level))

Arguments

ML.FORECAST takes the following arguments:

Output

ML.FORECAST returns the following columns:

The output of ML.FORECAST has the following properties:

ARIMA_PLUS example

The following example forecasts 30 time points with a confidence level of 0.8:

SELECT
  *
FROM
  ML.FORECAST(MODEL `mydataset.mymodel`,
    STRUCT(30 AS horizon, 0.8 AS confidence_level))

ARIMA_PLUS_XREG example

The following example forecasts 30 time points with a confidence level of 0.8 with future features:

SELECT
  *
FROM
  ML.FORECAST(MODEL `mydataset.mymodel`,
    STRUCT(30 AS horizon, 0.8 AS confidence_level),
    (SELECT * FROM `mydataset.mytable`))

Limitation

Applying any additional computation directly on top of ML.FORECAST's result columns might lead to an out-of-memory issue if the model size is too large. Examples are calculating minimum or maximum values, or adding to or subtracting from a particular column. If you are trying to filter on the forecasted value, it's highly recommended to consider the forecast with limit option as an alternative since it implements better algorithms.

What's next