Simple auto_arima modelΒΆ

This is a simple example of how we can fit an ARIMA model in several lines without knowing anything about our data or optimal hyper parameters.


../_images/sphx_glr_example_simple_fit_001.png

Out:

Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 1, 12); AIC=2891.624, BIC=2915.656, Fit time=1.591 seconds
Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3049.597, BIC=3055.604, Fit time=0.073 seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2895.906, BIC=2907.922, Fit time=0.498 seconds
Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 0, 1, 12); AIC=2917.891, BIC=2929.907, Fit time=0.907 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 0, 1, 12); AIC=2919.813, BIC=2940.840, Fit time=1.417 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 1, 12); AIC=2903.304, BIC=2930.339, Fit time=10.408 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2883.087, BIC=2904.115, Fit time=1.885 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2913.016, BIC=2931.040, Fit time=1.187 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2869.086, BIC=2893.118, Fit time=1.821 seconds
Fit ARIMA: order=(3, 1, 1) seasonal_order=(1, 0, 0, 12); AIC=2876.643, BIC=2897.670, Fit time=1.602 seconds
Fit ARIMA: order=(3, 1, 3) seasonal_order=(1, 0, 0, 12); AIC=2910.860, BIC=2937.895, Fit time=2.283 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(1, 0, 0, 12); AIC=2885.486, BIC=2903.510, Fit time=1.317 seconds
Fit ARIMA: order=(4, 1, 3) seasonal_order=(1, 0, 0, 12); AIC=2915.476, BIC=2945.516, Fit time=3.077 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(0, 0, 0, 12); AIC=2984.608, BIC=3005.636, Fit time=0.276 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2862.085, BIC=2889.120, Fit time=12.630 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(2, 0, 1, 12); AIC=2905.687, BIC=2935.726, Fit time=12.919 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2880.550, BIC=2904.582, Fit time=13.295 seconds
Fit ARIMA: order=(4, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(3, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2872.877, BIC=2896.909, Fit time=8.988 seconds
Fit ARIMA: order=(3, 1, 3) seasonal_order=(2, 0, 0, 12); AIC=2913.464, BIC=2943.504, Fit time=12.393 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2881.198, BIC=2902.225, Fit time=7.312 seconds
Fit ARIMA: order=(4, 1, 3) seasonal_order=(2, 0, 0, 12); AIC=2914.571, BIC=2947.614, Fit time=15.593 seconds
Total fit time: 111.482 seconds

print(__doc__)

# Author: Taylor Smith <taylor.smith@alkaline-ml.com>

import pmdarima as pm
import numpy as np
from matplotlib import pyplot as plt

# #############################################################################
# Load the data and split it into separate pieces
data = pm.datasets.load_wineind()
train, test = data[:150], data[150:]

# Fit a simple auto_arima model
arima = pm.auto_arima(train, error_action='ignore', trace=1,
                      seasonal=True, m=12)

# #############################################################################
# Plot actual test vs. forecasts:
x = np.arange(test.shape[0])
plt.scatter(x, test, marker='x')
plt.plot(x, arima.predict(n_periods=test.shape[0]))
plt.title('Actual test samples vs. forecasts')
plt.show()

Total running time of the script: ( 1 minutes 51.677 seconds)

Gallery generated by Sphinx-Gallery