Holt-Winters

In this section, I shall explain a modified form of the Holt-Winters exponential smoothing algorithm, which is quite useful for forecasting. Holt-Winters is a fairly simple algorithm. Here it is:

func hw(a stl.Result, periodicity, forward int, alpha, beta, gamma float64) []float64 {  level := make([]float64, len(a.Data))  trend := make([]float64, len(a.Trend))  seasonal := make([]float64, len(a.Seasonal))  forecast := make([]float64, len(a.Data)+forward)  copy(seasonal, a.Seasonal)  for i := range a.Data {    if i == 0 {      continue    }    level[i] = alpha*a.Data[i] + (1-alpha)*(level[i-1]+trend[i-1])    trend[i] = beta*(level[i]-level[i-1]) + (1-beta)*(trend[i-1])    if i-periodicity < 0 {      continue    } seasonal[i] = gamma*(a.Data[i]-level[i-1]-trend[i-1]) ...

Get Go Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.