• API

›Forecasting

Forecasting

  • Autoregressive Neural Network (AR_net)
  • Quadratic Model
  • Linear Model
  • KatsEnsemble
  • Empirical Confidence Interval
  • STLF
  • Theta
  • Holt-Winter’s
  • Prophet
  • SARIMA
  • ARIMA

Detection

  • BOCPD: Residual Translation
  • BOCPD: Bayesian Online Changepoint Detection
  • Outlier Detection
  • ACFDetector
  • Seasonality Detector
  • Cusum Detector

TSFeatures

  • TsFeatures

Multivariate

  • Multivariate Outlier Detection
  • VAR

Utilities

  • Model Hyperparameter Tuning
  • Backtesting
  • Time Series Decomposition
  • Dataswarm Operators

Holt-Winter’s

Holt-Winter’s model is expanding of simple exponential smoothing. It is also known as triple exponential smoothing. Holt-Winter’s is used for capturing both trend and seasonality. We assume the original time series, Y(t), could be expressed as combination of trend, level and seasonality.

  • Level: is the average value in the series.
  • Trend: is the increasing or decreasing value in the series.
  • Seasonality: is the repeating the short-term cycle in the series.
  • Noise: is the random variation in the series

There are two other method to build time series: additive and multiplicative.

Additive model: The effects of the individual factors are differentiated and added to model the data. Y(t) = Level + Trend + Seasonality

multiplicative model: Trend and seasonal components are multiplied. It is not linear, can be exponential or quadratic and represented by a curved line. Y(t) = LevelSeasonalityTrend

We implemented Holt-Winer’s with modules in statsmodels

API

# Parameter class
class HoltWintersParams(
    `trend=`**`None`**`,
    damped=`**`False`**`,
    seasonal=`**`None`**`,
    seasonal_periods=`**`None)`**

Parameters

trend: Type of trend component, {"add", “mul”, “additive”, “multiplicative”}
damped: Should the trend component be damped.
seasonal: Type of seasonal component. {“add”, “mul”, “additive”, “multiplicative”}
seasonal_periods: The number of periods in a complete seasonal cycle,
e.g., 4 for quarterly data or 7 for daily data with a weekly cycle.
# Model class
class HoltWintersModel()

Methods

fit(): # fit Holt-Winter's model with given parameters
predict(steps, freq): # predict the future for future steps

Example

We use air passenger data as an example fo Holt-Winter’s model

import pandas as pd
from infrastrategy.kats.consts import TimeSeriesData
from infrastrategy.kats.models.holtwinters import HoltWintersParams, HoltWintersModel
import plotly.graph_objects as go
from plotly.offline import init_notebook_mode
init_notebook_mode(connected=True)

# read and format data
file_path = "../data/air_passengers.csv"
data = pd.read_csv(file_path)
data.rename(columns={'ds': "time"}, inplace=True)
TSdata = TimeSeriesData(data)

# create Holt-Winter's parameters
params = HoltWintersParams(trend="mul", seasonal="mul", seasonal_periods=12)

# creat Holt-Winter's model
m = HoltWintersModel(params=params, data=TSdata)
m.fit()
fcst = m.predict(steps=60, freq="MS")

# plot
fig = go.Figure()
fig.add_trace(go.Scatter(x=data['time'], y=data['y'], name="actual"))
fig.add_trace(go.Scatter(x=fcst['time'], y=fcst['fcst'], name="forecast"))
fig.show()
← ThetaProphet →
  • API
    • Parameters
    • Methods
  • Example
Kats Project
More
GitHubStar
Facebook Open Source
Copyright © 2021 Kats Project @ Facebook