Python libraries
There are a few popular libraries for classical time-series modeling in Python, but the most popular by far is statsmodels. The following chart compares the popularity of libraries in terms of the number of stars on GitHub:

Figure 5.3: Popularity of Python libraries for classical time-series forecasting
Statsmodels is clearly the most popular among these libraries. I've only chosen to include libraries that are actively maintained and that implement the algorithms directly rather than importing them from other libraries. The SkTime or Darts libraries, for example, offer traditional forecasting models, but they are not implemented there, but in statsmodels.
pmdarima (originally pyramid-arima) contains a parameter search to help fit the best ARIMA model to univariate time-series. Anticipy contains a number of models, such as exponential decay and step models. Arch implements tools for financial econometrics and functionality for Autoregressive Conditional Heteroscedasticity (ARCH).
While not as active as Scikit-Learn and only maintained by a couple of people, statsmodels is the go-to library for traditional statistics and econometrics approaches to time-series, with a much stronger emphasis on parameter estimation and statistical testing than machine learning.
Statsmodels
The statsmodels library can help to estimate statistical models and perform statistical tests. It's built on SciPy and NumPy and has lots of statistical functions and models.
The following table illustrates some of the modeling classes relevant to this chapter:
Class |
Description |
|
Univariate Autoregression Model |
|
Autoregressive Integrated Moving Average (ARIMA) model |
|
Holt Winter's Exponential Smoothing |
|
Simple Exponential Smoothing |
Figure 5.4: A few models implemented in statsmodels
The ARIMA class also has functionality for SARIMA through a seasonal_order parameter, ARIMA, with seasonal components. By definition, ARIMA also supports MA, AR, and differencing (integration).
There are some other models, such as MarkovAutoregression, but we won't go through all of these – we will work through a selection.
Some other useful functions are listed here:
Function |
Description |
|
Kwiatkowski-Phillips-Schmidt-Shin test for stationarity |
|
Augmented Dickey-Fuller unit root test |
|
The cross-correlation function |
|
Partial autocorrelation estimate |
|
Engle's Test for Autoregressive Conditional Heteroscedasticity (ARCH), also referred to as the ARCH-LM test |
|
Ljung-Box Q Statistic |
|
Seasonal decomposition using moving averages |
|
Detrend a vector |
Figure 5.5: Useful functions in statsmodels
As a convention, we import statsmodels like this:
import statsmodels.api as sm
These statsmodels algorithms are also available through SkTime, which makes them available through an interface similar to the Sklearn interface.
This should be enough for a brief overview. Let's get into the modeling itself!