• 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

SARIMA

SARIMA model (stand for Seasonal Auto Regressive Integrated Moving Average, or Seasonal-ARIMA) is an extension of ARIMA model which is capable to modeling the time series data with seasonalities. SARIMA adds additional parameters to model the seasonalities beyond ARIMA model.

SARIMA contains two types of core parameters, seasonal parameters and non-seasonal parameters, where the non-seasonal parameters are defined in the same way as in ARIMA model.

  • Seasonal parameters

    • Seasonal AR (autoregressive) order
    • Seasonal differencing order to make the time series stationary.
    • Seasonal MA (moving average) order.
    • The number of time steps for a single seasonal period.
  • Non-seasonal parameters (same as in ARIMA)

    • AR (Autoregressive) order
    • Differencing order to make the time series stationary
    • MA (moving average) order

We use the implementation in statsmodels and re-write the API to adapt Kats development style. Please refer to statsmodel documentation for additional optional parameters for SARIMA.

API

# Parameter class
class SARIMAParams(p, d, q, trend, seasonal_order = (P, D, Q, m))

Parameters:

p: the order of AR term
d: the number of differencing to make the time series stationary
q: the order of MA term
P: the seasonal order of AR term
D: the seasonal order to make time series stationary
Q: the seasonal order of MA term
m: the number of time steps for a single seasonal period
# Model class
`class SARIMAModel(data, params)`
fit(): # fit SARIMA 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 SARIMA model

import pandas as pd
from infrastrategy.kats.consts import TimeSeriesData
from infrastrategy.kats.models.arima import SARIMAModel, SARIMAParams

# 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 SARIMAParam with specifying initial param values
params = SARIMAParams(p=2, d=1, q=1, trend='ct',
                      seasonal_order=(1,0,1,12))

# create SARIMAModel with given data and params
m = SARIMAModel(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()

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