.. _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=0.30 sec ARIMA(0,1,0)(0,0,0)[12] intercept : AIC=3049.597, Time=0.01 sec ARIMA(1,1,0)(1,0,0)[12] intercept : AIC=2954.973, Time=0.12 sec ARIMA(0,1,1)(0,0,1)[12] intercept : AIC=2947.014, Time=0.11 sec ARIMA(0,1,0)(0,0,0)[12] : AIC=3047.612, Time=0.01 sec ARIMA(2,1,2)(0,0,1)[12] intercept : AIC=2938.457, Time=0.20 sec ARIMA(2,1,2)(1,0,0)[12] intercept : AIC=2915.636, Time=0.21 sec ARIMA(2,1,2)(0,0,0)[12] intercept : AIC=2984.606, Time=0.09 sec ARIMA(2,1,2)(2,0,0)[12] intercept : AIC=2915.168, Time=1.56 sec ARIMA(2,1,2)(2,0,1)[12] intercept : AIC=2917.256, Time=2.41 sec ARIMA(1,1,2)(2,0,0)[12] intercept : AIC=2924.379, Time=1.90 sec ARIMA(2,1,1)(2,0,0)[12] intercept : AIC=2911.007, Time=1.59 sec ARIMA(2,1,1)(1,0,0)[12] intercept : AIC=2911.505, Time=0.24 sec ARIMA(2,1,1)(2,0,1)[12] intercept : AIC=2912.933, Time=1.18 sec ARIMA(2,1,1)(1,0,1)[12] intercept : AIC=2911.904, Time=0.28 sec ARIMA(1,1,1)(2,0,0)[12] intercept : AIC=2919.168, Time=0.72 sec ARIMA(2,1,0)(2,0,0)[12] intercept : AIC=2927.636, Time=1.81 sec ARIMA(3,1,1)(2,0,0)[12] intercept : AIC=2912.748, Time=2.50 sec ARIMA(1,1,0)(2,0,0)[12] intercept : AIC=2954.725, Time=1.51 sec ARIMA(3,1,0)(2,0,0)[12] intercept : AIC=2914.169, Time=2.29 sec ARIMA(3,1,2)(2,0,0)[12] intercept : AIC=2915.130, Time=1.78 sec ARIMA(2,1,1)(2,0,0)[12] : AIC=2908.085, Time=1.83 sec ARIMA(2,1,1)(1,0,0)[12] : AIC=2908.791, Time=0.33 sec ARIMA(2,1,1)(2,0,1)[12] : AIC=2909.997, Time=1.67 sec ARIMA(2,1,1)(1,0,1)[12] : AIC=2907.980, Time=0.31 sec ARIMA(2,1,1)(0,0,1)[12] : AIC=2932.875, Time=0.18 sec ARIMA(2,1,1)(1,0,2)[12] : AIC=2909.946, Time=2.21 sec ARIMA(2,1,1)(0,0,0)[12] : AIC=2979.838, Time=0.10 sec ARIMA(2,1,1)(0,0,2)[12] : AIC=2920.616, Time=1.77 sec ARIMA(2,1,1)(2,0,2)[12] : AIC=2911.929, Time=1.80 sec ARIMA(1,1,1)(1,0,1)[12] : AIC=2915.102, Time=0.32 sec ARIMA(2,1,0)(1,0,1)[12] : AIC=2925.280, Time=0.21 sec ARIMA(3,1,1)(1,0,1)[12] : AIC=2910.007, Time=0.31 sec ARIMA(2,1,2)(1,0,1)[12] : AIC=2913.030, Time=0.31 sec ARIMA(1,1,0)(1,0,1)[12] : AIC=2952.472, Time=0.21 sec ARIMA(1,1,2)(1,0,1)[12] : AIC=2922.341, Time=0.38 sec ARIMA(3,1,0)(1,0,1)[12] : AIC=2912.111, Time=0.29 sec ARIMA(3,1,2)(1,0,1)[12] : AIC=2913.230, Time=0.46 sec Best model: ARIMA(2,1,1)(1,0,1)[12] Total fit time: 33.510 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:** ( 0 minutes 33.530 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 `_