Documentation

holtWinters() function

Flux 0.38.0+

The holtWinters() function applies the Holt-Winters forecasting method to input tables.

Output data type: Float

holtWinters(
  n: 10,
  seasonality: 4,
  interval: 30d,
  withFit: false,
  timeColumn: "_time",
  column: "_value",
)

The Holt-Winters method predicts n seasonally-adjusted values for the specified column at the specified interval. For example, if interval is six minutes (6m) and n is 3, results include three predicted values six minutes apart.

Seasonality

seasonality delimits the length of a seasonal pattern according to interval. If your interval is two minutes (2m) and seasonality is 4, then the seasonal pattern occurs every eight minutes or every four data points. Likewise, if your interval is two months (2mo) and seasonality is 4, then the seasonal pattern occurs every eight months or every four data points. If data doesn’t have a seasonal pattern, set seasonality to 0.

Space values evenly in time

holtWinters() expects values evenly spaced in time. To ensure holtWinters() values are spaced evenly in time, the following rules apply:

  • Data is grouped into time-based “buckets” determined by the interval.
  • If a bucket includes many values, the first value is used.
  • If a bucket includes no values, a missing value (null) is added for that bucket.

By default, holtWinters() uses the first value in each time bucket to run the Holt-Winters calculation. To specify other values to use in the calculation, use:

Use aggregateWindow to normalize irregular times
data
  |> aggregateWindow(every: 1d, fn: first)
  |> holtWinters(n: 10, seasonality: 4, interval: 1d)

Fitted model

The holtWinters() function applies the Nelder-Mead optimization to include “fitted” data points in results when withFit is set to true.

Null timestamps

holtWinters() discards rows with null timestamps before running the Holt-Winters calculation.

Null values

holtWinters() treats null values as missing data points and includes them in the Holt-Winters calculation.

Parameters

n

(Required) The number of values to predict.

seasonality

The number of points in a season. Default is 0.

interval

(Required) The interval between two data points.

withFit

Return fitted data in results. Default is false.

timeColumn

The time column to use. Default is "_time".

column

The column to operate on. Default is "_value".

tables

Input data. Default is piped-forward data (<-).

Examples

The following examples use data provided by the sampledata package to show how holtWinters() transforms data.

Use holtWinters to predict future values

import "sampledata"

sampledata.int()
  |> holtWinters(n: 6, interval: 10s)

View input and output

Use holtWinters with seasonality to predict future values

import "sampledata"

sampledata.int()
  |> holtWinters(
    n: 4,
    interval: 10s,
    seasonality: 4
  )

View input and output

Use the holtWinters fitted model to predict future values

import "sampledata"

sampledata.int()
  |> holtWinters(
    n: 3,
    interval: 10s,
    withFit: true
  )

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.