alkaline-ml / pmdarima

A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.
https://www.alkaline-ml.com/pmdarima
MIT License
1.57k stars 231 forks source link

Retrieving Best model from ARIMA #505

Closed tobiasderoos closed 2 years ago

tobiasderoos commented 2 years ago

Describe the question you have

Hi,

If I use the Auto ARIMA function I get in the console the following message:

Best model: ARIMA(0,1,1)(0,0,0)[12]

How can I save the results of the parameters?

Versions (if necessary)

No response

aaronreidsmith commented 2 years ago

The model is essentially saying ARIMA(p, d, q)(P, D, Q)[s]. You can extract those values like so

>>> model = ARIMA(order=(0, 1, 1), seasonal_order=(0, 0, 0, 12))
>>> (p, d, q) = model.order
>>> (P, D, Q, s) = model.seasonal_order

Here are some docs around those properties:

order : iterable or array-like, shape=(3,)

The (p,d,q) order of the model for the number of AR parameters, differences, and MA parameters to use. p is the order (number of time lags) of the auto-regressive model, and is a non-negative integer. d is the degree of differencing (the number of times the data have had past values subtracted), and is a non-negative integer. q is the order of the moving-average model, and is a non-negative integer.

seasonal_order : array-like, shape=(4,), optional (default=(0, 0, 0, 0))

The (P,D,Q,s) order of the seasonal component of the model for the AR parameters, differences, MA parameters, and periodicity. D must be an integer indicating the integration order of the process, while P and Q may either be an integers indicating the AR and MA orders (so that all lags up to those orders are included) or else iterables giving specific AR and / or MA lags to include. S is an integer giving the periodicity (number of periods in season), often it is 4 for quarterly data or 12 for monthly data. Default is no seasonal effect.

tgsmith61591 commented 2 years ago

If you're using auto_arima to arrive at that model, note that auto_arima will return the best-fit model.

return_valid_fits : bool, optional (default=False) If True, will return all valid ARIMA fits in a list. If False (by default), will only return the best fit.

Doc here