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:
Performing stepwise search to minimize aic
Fit ARIMA(2,1,2)x(1,0,1,12) [intercept=True]; AIC=2915.641, BIC=2939.673, Time=0.792 seconds
Fit ARIMA(0,1,0)x(0,0,0,12) [intercept=True]; AIC=3049.597, BIC=3055.604, Time=0.014 seconds
Fit ARIMA(1,1,0)x(1,0,0,12) [intercept=True]; AIC=2954.973, BIC=2966.989, Time=0.423 seconds
Fit ARIMA(0,1,1)x(0,0,1,12) [intercept=True]; AIC=2947.014, BIC=2959.029, Time=0.453 seconds
Fit ARIMA(0,1,0)x(0,0,0,12) [intercept=False]; AIC=3047.612, BIC=3050.616, Time=0.010 seconds
Fit ARIMA(2,1,2)x(0,0,1,12) [intercept=True]; AIC=2938.457, BIC=2959.484, Time=0.506 seconds
Fit ARIMA(2,1,2)x(1,0,0,12) [intercept=True]; AIC=2915.636, BIC=2936.664, Time=0.675 seconds
Fit ARIMA(2,1,2)x(0,0,0,12) [intercept=True]; AIC=2984.606, BIC=3002.630, Time=0.153 seconds
Fit ARIMA(2,1,2)x(2,0,0,12) [intercept=True]; AIC=2915.168, BIC=2939.200, Time=7.226 seconds
Fit ARIMA(2,1,2)x(2,0,1,12) [intercept=True]; AIC=2917.256, BIC=2944.291, Time=7.105 seconds
Fit ARIMA(1,1,2)x(2,0,0,12) [intercept=True]; AIC=2924.379, BIC=2945.407, Time=7.497 seconds
Fit ARIMA(2,1,1)x(2,0,0,12) [intercept=True]; AIC=2911.007, BIC=2932.034, Time=5.897 seconds
Fit ARIMA(2,1,1)x(1,0,0,12) [intercept=True]; AIC=2911.505, BIC=2929.528, Time=0.432 seconds
Fit ARIMA(2,1,1)x(2,0,1,12) [intercept=True]; AIC=2912.933, BIC=2936.965, Time=5.764 seconds
Fit ARIMA(2,1,1)x(1,0,1,12) [intercept=True]; AIC=2911.904, BIC=2932.932, Time=0.507 seconds
Fit ARIMA(1,1,1)x(2,0,0,12) [intercept=True]; AIC=2919.168, BIC=2937.192, Time=3.718 seconds
Fit ARIMA(2,1,0)x(2,0,0,12) [intercept=True]; AIC=2927.636, BIC=2945.660, Time=6.163 seconds
Fit ARIMA(3,1,1)x(2,0,0,12) [intercept=True]; AIC=2912.748, BIC=2936.780, Time=5.447 seconds
Fit ARIMA(1,1,0)x(2,0,0,12) [intercept=True]; AIC=2954.725, BIC=2969.745, Time=4.099 seconds
Fit ARIMA(3,1,0)x(2,0,0,12) [intercept=True]; AIC=2914.169, BIC=2935.197, Time=6.390 seconds
Fit ARIMA(3,1,2)x(2,0,0,12) [intercept=True]; AIC=2915.130, BIC=2942.165, Time=5.868 seconds
Total fit time: 69.175 seconds
print(__doc__)
# Author: Taylor Smith <taylor.smith@alkaline-ml.com>
import pmdarima as pm
from pmdarima import model_selection
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 = model_selection.train_test_split(data, train_size=150)
# Fit a simple auto_arima model
arima = pm.auto_arima(train, error_action='ignore', trace=True,
suppress_warnings=True, maxiter=10,
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 9.198 seconds)