Skip to content

Univariate and multivariate time series forecasting, with uncertainty quantification (Python & R)

License

Notifications You must be signed in to change notification settings

Techtonique/ahead_python

Repository files navigation

ahead

PyPI PyPI - License PyPI Downloads Conda Downloads HitCount CodeFactor Documentation

Welcome to ahead (Python version; the R version is here).

ahead is a package for univariate and multivariate time series forecasting, with uncertainty quantification. The Python version is built on top of the R package with the same name. ahead's source code is available on GitHub.

Currently, 6 forecasting methods are implemented in the Python package:

  • DynamicRegressor: univariate time series forecasting method adapted from forecast::nnetar. The Python implementation contains only the automatic version.
  • EAT: univariate time series forecasting method based on combinations of R's forecast::ets, forecast::auto.arima, and forecast::thetaf
  • ArmaGarch: univariate forecasting simulations of an ARMA(1, 1)-GARCH(1, 1)
  • BasicForecaster: multivariate time series forecasting methods; mean, median and random walk
  • Ridge2Regressor: multivariate time series forecasting method, based on quasi-randomized networks and presented in this paper
  • VAR: multivariate time series forecasting method using Vector AutoRegressive model (VAR, mostly here for benchmarking purpose)

Installing

  • From Pypi, stable version:
pip install ahead --verbose
  • From Github, for the development version:
pip install git+https://github.com/Techtonique/ahead_python.git --verbose

Quickstart

Univariate time series

import pandas as pd
from ahead import DynamicRegressor # might take some time, but ONLY the 1st time it's called

# Data frame containing the time series 
dataset = {
'date' : ['2020-01-01', '2020-02-01', '2020-03-01', '2020-04-01', '2020-05-01'],
'value' : [34, 30, 35.6, 33.3, 38.1]}

df = pd.DataFrame(dataset).set_index('date')
print(df)

# univariate time series forecasting 
d1 = DynamicRegressor(h = 5)
d1.forecast(df)
print(d1.result_df_)

Multivariate time series

import pandas as pd
from ahead import Ridge2Regressor # might take some time, but ONLY the 1st time it's called

# Data frame containing the (3) time series
dataset = {
 'date' : ['2001-01-01', '2002-01-01', '2003-01-01', '2004-01-01', '2005-01-01'],
 'series1' : [34, 30, 35.6, 33.3, 38.1],    
 'series2' : [4, 5.5, 5.6, 6.3, 5.1],
 'series3' : [100, 100.5, 100.6, 100.2, 100.1]}
df = pd.DataFrame(dataset).set_index('date')
print(df)

# multivariate time series forecasting 
r1 = Ridge2Regressor(h = 5)
r1.forecast(df)
print(r1.result_dfs_)

Contributing

Want to contribute to ahead's development on Github, read this!

License

BSD 3-Clause © Thierry Moudiki, 2021.