Python implementations of time series forecasting and anomaly detection


7 October 2022

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.


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 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 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.


The first attempt to port my auto.arima() function to Python was pmdarima. This is also behind the AutoARIMA() function in 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:


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


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 is a Python library for wrangling and forecasting time series. It includes wrappers for ETS and ARIMA models from statsforecast and pmdarima, as well as an implementation of TBATS and some reconciliation functionality.


Assimakopoulos, V., & Nikolopoulos, K. (2000). The theta model: A decomposition approach to forecasting. International Journal of Forecasting, 16(4), 521–530.
Bandara, K., Hyndman, R. J., & Bergmeir, C. (2022). MSTL: A seasonal-trend decomposition algorithm for time series with multiple seasonal patterns. International J Operational Research.
Bergmeir, C., Hyndman, R. J., & Benıtez, J. M. (2016). Bagging exponential smoothing methods using STL decomposition and Box-Cox transformation. International Journal of Forecasting, 32(2), 303–312.
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.
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.
Hyndman, R. J., & Billah, M. B. (2003). Unmasking the theta method. International Journal of Forecasting, 19(2), 287–290.
Hyndman, R. J., & Khandakar, Y. (2008). Automatic time series forecasting: The forecast package for R. Journal of Statistical Software, 26(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 Journal of Forecasting, 18(3), 439–454.
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.
Hyndman, R. J., & Shang, H. L. (2010). Rainbow plots, bagplots and boxplots for functional data. J Computational & Graphical Statistics, 19(1), 29–45.
Kandanaarachchi, S., & Hyndman, R. J. (2021). Dimension reduction for outlier detection using DOBIN. J Computational & Graphical Statistics, 30(1), 204–219.
Kang, Y., Hyndman, R. J., & Smith-Miles, K. (2017). Visualising forecasting algorithm performance using time series instance spaces. International Journal of Forecasting, 33(2), 345–358.
Montero-Manso, P., Athanasopoulos, G., Hyndman, R. J., & Talagala, T. S. (2020). FFORMA: Feature-based forecast model averaging. International Journal of Forecasting, 36(1), 86–92.
Shenstone, L., & Hyndman, R. J. (2005). Stochastic models underlying croston’s method for intermittent demand forecasting. Journal of Forecasting, 24(6), 389–402.
Talagala, P. D., Hyndman, R. J., & Smith-Miles, K. (2021). Anomaly detection in high-dimensional data. J Computational & Graphical Statistics, 30(2), 360–374.
Talagala, T. S., Hyndman, R. J., & Athanasopoulos, G. (2018). Meta-learning how to forecast time series (Working Paper No. 6/18). Department of Econometrics & Business Statistics, Monash University.
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.