.. _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:: Performing stepwise search to minimize aic ARIMA(2,1,2)(1,0,1)[12] intercept : AIC=2915.641, Time=8.22 sec ARIMA(0,1,0)(0,0,0)[12] intercept : AIC=3049.597, Time=0.09 sec ARIMA(1,1,0)(1,0,0)[12] intercept : AIC=2954.973, Time=3.42 sec ARIMA(0,1,1)(0,0,1)[12] intercept : AIC=2947.014, Time=4.20 sec ARIMA(0,1,0)(0,0,0)[12] : AIC=3047.612, Time=0.07 sec ARIMA(2,1,2)(0,0,1)[12] intercept : AIC=2938.457, Time=7.53 sec ARIMA(2,1,2)(1,0,0)[12] intercept : AIC=2915.636, Time=6.76 sec ARIMA(2,1,2)(0,0,0)[12] intercept : AIC=2984.606, Time=0.15 sec ARIMA(2,1,2)(2,0,0)[12] intercept : AIC=2915.168, Time=21.95 sec ARIMA(2,1,2)(2,0,1)[12] intercept : AIC=2917.256, Time=28.60 sec ARIMA(1,1,2)(2,0,0)[12] intercept : AIC=2924.379, Time=25.33 sec ARIMA(2,1,1)(2,0,0)[12] intercept : AIC=2911.007, Time=24.57 sec ARIMA(2,1,1)(1,0,0)[12] intercept : AIC=2911.505, Time=7.82 sec ARIMA(2,1,1)(2,0,1)[12] intercept : AIC=2912.933, Time=23.59 sec ARIMA(2,1,1)(1,0,1)[12] intercept : AIC=2911.904, Time=7.20 sec ARIMA(1,1,1)(2,0,0)[12] intercept : AIC=2919.168, Time=18.49 sec ARIMA(2,1,0)(2,0,0)[12] intercept : AIC=2927.636, Time=23.31 sec ARIMA(3,1,1)(2,0,0)[12] intercept : AIC=2912.748, Time=25.20 sec ARIMA(1,1,0)(2,0,0)[12] intercept : AIC=2954.725, Time=20.29 sec ARIMA(3,1,0)(2,0,0)[12] intercept : AIC=2914.169, Time=26.13 sec ARIMA(3,1,2)(2,0,0)[12] intercept : AIC=2915.130, Time=31.39 sec ARIMA(2,1,1)(2,0,0)[12] : AIC=2908.085, Time=21.58 sec ARIMA(2,1,1)(1,0,0)[12] : AIC=2908.791, Time=7.09 sec ARIMA(2,1,1)(2,0,1)[12] : AIC=2909.997, Time=20.50 sec ARIMA(2,1,1)(1,0,1)[12] : AIC=2907.980, Time=6.94 sec ARIMA(2,1,1)(0,0,1)[12] : AIC=2932.875, Time=6.57 sec ARIMA(2,1,1)(1,0,2)[12] : AIC=2909.946, Time=21.90 sec ARIMA(2,1,1)(0,0,0)[12] : AIC=2979.838, Time=0.05 sec ARIMA(2,1,1)(0,0,2)[12] : AIC=2920.616, Time=18.59 sec ARIMA(2,1,1)(2,0,2)[12] : AIC=2911.929, Time=24.35 sec ARIMA(1,1,1)(1,0,1)[12] : AIC=2915.102, Time=5.15 sec ARIMA(2,1,0)(1,0,1)[12] : AIC=2925.280, Time=5.40 sec ARIMA(3,1,1)(1,0,1)[12] : AIC=2910.007, Time=7.98 sec ARIMA(2,1,2)(1,0,1)[12] : AIC=2913.030, Time=8.69 sec ARIMA(1,1,0)(1,0,1)[12] : AIC=2952.472, Time=4.01 sec ARIMA(1,1,2)(1,0,1)[12] : AIC=2922.341, Time=6.39 sec ARIMA(3,1,0)(1,0,1)[12] : AIC=2912.111, Time=7.22 sec ARIMA(3,1,2)(1,0,1)[12] : AIC=2913.230, Time=8.30 sec Best model: ARIMA(2,1,1)(1,0,1)[12] Total fit time: 495.266 seconds | .. code-block:: python print(__doc__) # Author: Taylor Smith 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:** ( 8 minutes 15.379 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 `_