.. _sphx_glr_auto_examples_example_simple_fit.py: ======================= 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. .. raw:: html
.. image:: /auto_examples/images/sphx_glr_example_simple_fit_001.png :align: center .. rst-class:: sphx-glr-script-out Out:: Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 1, 12); AIC=2908.451, BIC=2932.482, Fit time=1.434 seconds Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3049.597, BIC=3055.604, Fit time=0.007 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2895.934, BIC=2907.950, Fit time=0.395 seconds Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 0, 1, 12); AIC=2917.891, BIC=2929.907, Fit time=0.601 seconds Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3047.612, BIC=3050.616, Fit time=0.005 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3039.240, BIC=3048.252, Fit time=0.017 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2890.929, BIC=2905.949, Fit time=4.935 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(2, 0, 1, 12); AIC=2892.498, BIC=2910.522, Fit time=10.920 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 1, 12); AIC=2890.523, BIC=2905.543, Fit time=0.882 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(0, 0, 1, 12); AIC=2981.524, BIC=2993.540, Fit time=0.063 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 2, 12); AIC=2892.534, BIC=2910.558, Fit time=8.653 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(0, 0, 2, 12); AIC=2931.096, BIC=2946.116, Fit time=4.683 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(2, 0, 2, 12); AIC=nan, BIC=nan, Fit time=nan seconds Fit ARIMA: order=(0, 1, 0) seasonal_order=(1, 0, 1, 12); AIC=2906.713, BIC=2918.728, Fit time=0.455 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(1, 0, 1, 12); AIC=2872.445, BIC=2890.469, Fit time=0.837 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(0, 0, 1, 12); AIC=2936.368, BIC=2951.387, Fit time=0.520 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2879.303, BIC=2894.322, Fit time=0.717 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(2, 0, 1, 12); AIC=2875.058, BIC=2896.086, Fit time=13.213 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(1, 0, 2, 12); AIC=2874.354, BIC=2895.381, Fit time=10.173 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3009.052, BIC=3021.068, Fit time=0.097 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(0, 0, 2, 12); AIC=2909.242, BIC=2927.266, Fit time=4.978 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2873.301, BIC=2891.325, Fit time=8.574 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(2, 0, 2, 12); AIC=2908.152, BIC=2932.184, Fit time=14.423 seconds Near non-invertible roots for order (2, 1, 0)(2, 0, 2, 12); setting score to inf (at least one inverse root too close to the border of the unit circle: 1.000) Fit ARIMA: order=(3, 1, 0) seasonal_order=(1, 0, 1, 12); AIC=2866.093, BIC=2887.121, Fit time=2.287 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(0, 0, 1, 12); AIC=2922.454, BIC=2940.478, Fit time=0.679 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2870.467, BIC=2888.491, Fit time=1.131 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(2, 0, 1, 12); AIC=2867.919, BIC=2891.951, Fit time=21.227 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(1, 0, 2, 12); AIC=2867.994, BIC=2892.025, Fit time=13.736 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=2992.003, BIC=3007.023, Fit time=0.096 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(0, 0, 2, 12); AIC=2896.298, BIC=2917.326, Fit time=6.601 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2866.267, BIC=2887.294, Fit time=19.037 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(2, 0, 2, 12); AIC=2910.067, BIC=2937.103, Fit time=17.823 seconds Near non-invertible roots for order (3, 1, 0)(2, 0, 2, 12); setting score to inf (at least one inverse root too close to the border of the unit circle: 1.000) Fit ARIMA: order=(4, 1, 0) seasonal_order=(1, 0, 1, 12); AIC=2859.210, BIC=2883.241, Fit time=1.852 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(0, 0, 1, 12); AIC=2939.352, BIC=2960.379, Fit time=0.207 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2866.318, BIC=2887.345, Fit time=1.335 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(2, 0, 1, 12); AIC=2863.844, BIC=2890.879, Fit time=32.005 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(1, 0, 2, 12); AIC=2860.627, BIC=2887.663, Fit time=13.669 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=2992.338, BIC=3010.362, Fit time=0.116 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(0, 0, 2, 12); AIC=2894.298, BIC=2918.329, Fit time=8.579 seconds Fit ARIMA: order=(4, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2858.880, BIC=2882.912, Fit time=28.081 seconds Fit ARIMA: order=(5, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2860.023, BIC=2887.059, Fit time=29.535 seconds Near non-invertible roots for order (5, 1, 0)(2, 0, 0, 12); setting score to inf (at least one inverse root too close to the border of the unit circle: 0.990) Fit ARIMA: order=(4, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2870.532, BIC=2897.567, Fit time=23.413 seconds Fit ARIMA: order=(3, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2881.360, BIC=2905.391, Fit time=40.068 seconds Fit ARIMA: order=(5, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2868.950, BIC=2898.990, Fit time=40.949 seconds Total fit time: 399.578 seconds | .. code-block:: python print(__doc__) # Author: Taylor Smith 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, suppress_warnings=True, 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:** ( 6 minutes 39.833 seconds) .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: example_simple_fit.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: example_simple_fit.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_