• 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

Linear Model

Using simple linear regression to explore relationship between observed value and time. For prediction intervals, we use weighted standard deviation method to get standard error and get prediction interval band.

API

# Parameter class
class LinearModelParams(alpha=0.05**`)`**

Parameters

alpha: `confidence level for two-sided hypothesis`
# Model class
class LinearModel()

Methods

fit(): # fit linear model with given parameters
predict(steps, freq): # predict the future for future steps
plot(): # plot forecaset reslut

Example

We use air passenger data as an example.

import pandas as pd
from infrastrategy.kats.consts import TimeSeriesData
from infrastrategy.kats.models.linearModel  import LinearModelParams, LinearModel


# 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 parameters
params = LinearModelParams()

# creat model
m = LinearModel(params=params, data=TSdata)
m.fit()
fcst = m.predict(steps=60, freq="MS")

# plot forecast result
m.plot()

← Quadratic ModelKatsEnsemble →
  • API
    • Parameters
    • Methods
  • Example
Kats Project
More
GitHubStar
Facebook Open Source
Copyright © 2021 Kats Project @ Facebook