Grid search SARIMAX and ARIMA models¶
SARIMAX (Seasonal Auto-Regressive Integrated Moving Average with eXogenous factors) is a generalization of the ARIMA model that allows incorporating seasonality and exogenous variables. This model have a total of 6 hyperparameters that must specified when training the model:
-
p: Trend autoregression order.
-
d: Trend difference order.
-
q: Trend moving average order.
-
P: Seasonal autoregressive order.
-
D: Seasonal difference order.
-
Q: Seasonal moving average order.
-
m: The number of time steps for a single seasonal period.
One way to find the best values is by using grid search. The grid_search_sarimax
function of the skforecast.model_selection_statsmodels module is a wrapper that automates this process using the SARIMAX implementation available in the statsmodels library.
Libraries¶
1 2 3 4 |
|
Data¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Grid search¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 |
|
1 |
|
params | metric | order | seasonal_order | trend |
---|---|---|---|---|
{'order': (12, 1, 1), 'seasonal_order': (0, 0, 0, 0), 'trend': None} | 0.0504759 | (12, 1, 1) | (0, 0, 0, 0) | |
{'order': (12, 1, 1), 'seasonal_order': (0, 0, 0, 0), 'trend': 'n'} | 0.0504759 | (12, 1, 1) | (0, 0, 0, 0) | n |
{'order': (14, 1, 4), 'seasonal_order': (0, 0, 0, 0), 'trend': None} | 0.0505509 | (14, 1, 4) | (0, 0, 0, 0) | |
{'order': (14, 1, 4), 'seasonal_order': (0, 0, 0, 0), 'trend': 'n'} | 0.0505509 | (14, 1, 4) | (0, 0, 0, 0) | n |
{'order': (12, 1, 1), 'seasonal_order': (0, 0, 0, 0), 'trend': 'c'} | 0.0518921 | (12, 1, 1) | (0, 0, 0, 0) | c |
{'order': (12, 1, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': None} | 0.0528397 | (12, 1, 0) | (0, 0, 0, 0) | |
{'order': (12, 1, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'n'} | 0.0528397 | (12, 1, 0) | (0, 0, 0, 0) | n |
{'order': (12, 1, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'c'} | 0.0534996 | (12, 1, 0) | (0, 0, 0, 0) | c |
{'order': (14, 1, 4), 'seasonal_order': (0, 0, 0, 0), 'trend': 'c'} | 0.0537079 | (14, 1, 4) | (0, 0, 0, 0) | c |
{'order': (12, 2, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': None} | 0.054425 | (12, 2, 0) | (0, 0, 0, 0) | |
{'order': (12, 2, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'n'} | 0.054425 | (12, 2, 0) | (0, 0, 0, 0) | n |
{'order': (12, 2, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'c'} | 0.0544985 | (12, 2, 0) | (0, 0, 0, 0) | c |
{'order': (12, 0, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': None} | 0.0636531 | (12, 0, 0) | (0, 0, 0, 0) | |
{'order': (12, 0, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'n'} | 0.0636531 | (12, 0, 0) | (0, 0, 0, 0) | n |
{'order': (12, 0, 0), 'seasonal_order': (0, 0, 0, 0), 'trend': 'c'} | 0.0640216 | (12, 0, 0) | (0, 0, 0, 0) | c |