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.
Out:
Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 1, 12); AIC=2891.624, BIC=2915.656, Fit time=1.211 seconds
Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3049.597, BIC=3055.604, Fit time=0.041 seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2895.906, BIC=2907.922, Fit time=0.356 seconds
Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 0, 1, 12); AIC=2917.891, BIC=2929.907, Fit time=0.608 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 0, 1, 12); AIC=2919.813, BIC=2940.840, Fit time=0.967 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 1, 12); AIC=2903.304, BIC=2930.339, Fit time=6.689 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2883.087, BIC=2904.115, Fit time=1.089 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2913.016, BIC=2931.040, Fit time=0.642 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2869.086, BIC=2893.118, Fit time=1.296 seconds
Fit ARIMA: order=(3, 1, 1) seasonal_order=(1, 0, 0, 12); AIC=2876.643, BIC=2897.670, Fit time=0.997 seconds
Fit ARIMA: order=(3, 1, 3) seasonal_order=(1, 0, 0, 12); AIC=2910.860, BIC=2937.895, Fit time=1.512 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(1, 0, 0, 12); AIC=2885.486, BIC=2903.510, Fit time=0.951 seconds
Fit ARIMA: order=(4, 1, 3) seasonal_order=(1, 0, 0, 12); AIC=2915.476, BIC=2945.516, Fit time=2.044 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(0, 0, 0, 12); AIC=2984.608, BIC=3005.636, Fit time=0.255 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2862.085, BIC=2889.120, Fit time=8.902 seconds
Fit ARIMA: order=(3, 1, 2) seasonal_order=(2, 0, 1, 12); AIC=2905.687, BIC=2935.726, Fit time=8.708 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2880.550, BIC=2904.582, Fit time=7.493 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=7.086 seconds
Fit ARIMA: order=(3, 1, 3) seasonal_order=(2, 0, 0, 12); AIC=2913.464, BIC=2943.504, Fit time=8.607 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2881.198, BIC=2902.225, Fit time=6.299 seconds
Fit ARIMA: order=(4, 1, 3) seasonal_order=(2, 0, 0, 12); AIC=2914.571, BIC=2947.614, Fit time=11.215 seconds
Total fit time: 76.984 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 17.075 seconds)