Python implementations of time series forecasting and anomaly detection

Date

7 October 2022

Topics
Python
forecasting
anomalies
hts
Regular readers will know that I develop statistical models and algorithms, and I write R implementations of them. I’m often asked if there are also Python implementations available. There are.

Nixtla

The best Python implementations for my time series methods are available from Nixtla. Here are some of their packages related to my work, all compatible with scikit-learn.

They have also produced a lot of other great time series tools that are fast (optimized using numba) and perform well compared to various alternatives.

GluonTS

GluonTS from Amazon is excellent and provides lots of probabilistic time series forecasting models, with wrappers to some of my R code, and statsforecast from Nixtla. The other models in GluonTS are also well worth exploring.

Merlion

Merlion from Salesforce is another interesting python library which includes both my automatic ARIMA and automatic ETS algorithms, along with other forecasting methods. It also has some anomaly detection methods for time series.

pmdarima

The first attempt to port my auto.arima() function to Python was pmdarima.

sktime

sktime has the most complete set of time series methods for Python including

and more. These are also compatible with scikit-learn.

Recently, Kate Buchhorn has ported some of my anomaly detection algorithms to Python and made them available in sktime including:

statsmodels

The statsmodels collection includes a few functions based on my work:

pyhts

Bohan Zhang has produced pyhts, a re-implementation of the hts package in Python, based on Hyndman et al. (2011), Hyndman et al. (2016) and Wickramasuriya et al. (2019).

Darts

Darts is a Python library for wrangling and forecasting time series. It includes wrappers for ETS, ARIMA and other models from statsforecast and pmdarima, and some reconciliation functionality.

References

Assimakopoulos, V., & Nikolopoulos, K. (2000). The theta model: A decomposition approach to forecasting. International Journal of Forecasting, 16(4), 521–530. https://doi.org/10.1016/S0169-2070(00)00066-2
Bandara, K., Hyndman, R. J., & Bergmeir, C. (2025). MSTL: A seasonal-trend decomposition algorithm for time series with multiple seasonal patterns. International J Operational Research, 52(1). https://doi.org/10.1504/IJOR.2022.10048281
Bergmeir, C., Hyndman, R. J., & Benítez, J. M. (2016). Bagging exponential smoothing methods using STL decomposition and Box-Cox transformation. International J Forecasting, 32(2), 303–312. https://doi.org/10.1016/j.ijforecast.2015.07.002
De Livera, A. M., Hyndman, R. J., & Snyder, R. D. (2011). Forecasting time series with complex seasonal patterns using exponential smoothing. J American Statistical Association, 106(496), 1513–1527. https://doi.org/10.1198/jasa.2011.tm09771
Hyndman, R. J., Ahmed, R. A., Athanasopoulos, G., & Shang, H. L. (2011). Optimal combination forecasts for hierarchical time series. Computational Statistics & Data Analysis, 55(9), 2579–2589. https://doi.org/10.1016/j.csda.2011.03.006
Hyndman, R. J., & Billah, M. B. (2003). Unmasking the theta method. International J Forecasting, 19(2), 287–290. https://doi.org/10.1016/S0169-2070%2801%2900143-1
Hyndman, R. J., & Khandakar, Y. (2008). Automatic time series forecasting: The forecast package for R. J Statistical Software, 27(3), 1–22.
Hyndman, R. J., Koehler, A. B., Snyder, R. D., & Grose, S. (2002). A state space framework for automatic forecasting using exponential smoothing methods. International J Forecasting, 18(3), 439–454. https://doi.org/10.1016/S0169-2070%2801%2900110-8
Hyndman, R. J., Lee, A., & Wang, E. (2016). Fast computation of reconciled forecasts for hierarchical and grouped time series. Computational Statistics & Data Analysis, 97, 16–32. https://doi.org/10.1016/j.csda.2015.11.007
Hyndman, R. J., & Shang, H. L. (2010). Rainbow plots, bagplots and boxplots for functional data. J Computational & Graphical Statistics, 19(1), 29–45. https://doi.org/10.1198/jcgs.2009.08158
Kandanaarachchi, S., & Hyndman, R. J. (2021). Dimension reduction for outlier detection using DOBIN. J Computational & Graphical Statistics, 30(1), 204–219. https://doi.org/10.1080/10618600.2020.1807353
Kang, Y., Hyndman, R. J., & Smith-Miles, K. (2017). Visualising forecasting algorithm performance using time series instance spaces. International J Forecasting, 33(2), 345–358. https://doi.org/10.1016/j.ijforecast.2016.09.004
Montero-Manso, P., Athanasopoulos, G., Hyndman, R. J., & Talagala, T. S. (2020). FFORMA: Feature-based forecast model averaging. International J Forecasting, 36(1), 86–92. https://doi.org/10.1016/j.ijforecast.2019.02.011
Shenstone, L., & Hyndman, R. J. (2005). Stochastic models underlying croston’s method for intermittent demand forecasting. J Forecasting, 24(6), 389–402. https://doi.org/10.1002/for.963
Talagala, P. D., Hyndman, R. J., & Smith-Miles, K. (2021). Anomaly detection in high-dimensional data. J Computational & Graphical Statistics, 30(2), 360–374. https://doi.org/10.1080/10618600.2020.1807997
Talagala, T. S., Hyndman, R. J., & Athanasopoulos, G. (2023). Meta-learning how to forecast time series. J Forecasting, 42(6), 1476–1501. https://doi.org/10.1002/for.2963
Wickramasuriya, S. L., Athanasopoulos, G., & Hyndman, R. J. (2019). Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization. J American Statistical Association, 114(526), 804–819. https://doi.org/10.1080/01621459.2018.1448825