• 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

STLF

STLF, stands for STL-based Forecasting, where STL (Seasonal and Trend decomposition using Loess) is a time series decomposition algorithm. The procedure is listed as follows

  • Decomposition. We first apply multiplicative STL decomposition to the given time series data, and decompose it to seasonal and de-seasonalized components.
  • De-seasonalization. Assume seasonal component remains the same, and modeling the de-seasonalized component with different methods: linear, quadratic, prophet, and theta.
  • Re-seasonalization. We combine the seasonal and forecasted de-seasonalized components to produce final forecasts, we re-use the uncertainty interval from different methods.

API

# Parameter class
class STLFParams(method, m)

Parameters:

method: base forecasting model, currently support linear/quadratic/prophet/theta
m: length of seasonality
# Model class
`class STLFModel(data, params)`
fit(): # fit STLF model with given parameters
predict(steps, freq): # predict the future for future steps
plot(): # plot the time series data with confidence internal (if exist)

Example

We use air passenger data as an example for STLF model

import pandas as pd
from infrastrategy.kats.consts import TimeSeriesData
from infrastrategy.kats.models.arima import STLFModel, STLFParams

# read data and rename the two columns required by TimeSeriesData structure
data = pd.read_csv("../data/example_air_passengers.csv")
data.columns = ["time", "y"]
TSdata = TimeSeriesData(data)

# create STLFParam with specifying initial param values
# we choose quadratic model for demo
params = STLFParams(m=12, method="quadratic")

# create STLFModel with given data and params
m = STLFModel(data=TSdata, params=params)

# call fit method to fit model
m.fit()

# call predict method to predict the next 30 steps
m.predict(steps=30, freq="MS")

# visualize the results
m.plot()

← Empirical Confidence IntervalTheta →
  • API
    • Parameters:
  • Example
Kats Project
More
GitHubStar
Facebook Open Source
Copyright © 2021 Kats Project @ Facebook