.. _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.873, Time=4.00 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.975, Time=1.70 sec ARIMA(0,1,1)(0,0,1)[12] intercept : AIC=2947.028, Time=1.41 sec ARIMA(0,1,0)(0,0,0)[12] : AIC=3047.612, Time=0.08 sec ARIMA(2,1,2)(0,0,1)[12] intercept : AIC=2940.108, Time=2.73 sec ARIMA(2,1,2)(1,0,0)[12] intercept : AIC=2915.651, Time=2.50 sec ARIMA(2,1,2)(0,0,0)[12] intercept : AIC=2986.348, Time=0.21 sec ARIMA(2,1,2)(2,0,0)[12] intercept : AIC=2915.275, Time=12.74 sec ARIMA(2,1,2)(2,0,1)[12] intercept : AIC=2918.411, Time=16.02 sec ARIMA(1,1,2)(2,0,0)[12] intercept : AIC=2925.080, Time=15.50 sec ARIMA(2,1,1)(2,0,0)[12] intercept : AIC=2911.330, Time=16.67 sec ARIMA(2,1,1)(1,0,0)[12] intercept : AIC=2911.555, Time=3.31 sec ARIMA(2,1,1)(2,0,1)[12] intercept : AIC=2914.196, Time=15.50 sec ARIMA(2,1,1)(1,0,1)[12] intercept : AIC=2912.289, Time=3.01 sec ARIMA(1,1,1)(2,0,0)[12] intercept : AIC=2920.327, Time=10.56 sec ARIMA(2,1,0)(2,0,0)[12] intercept : AIC=2928.273, Time=16.25 sec ARIMA(3,1,1)(2,0,0)[12] intercept : AIC=2912.939, Time=17.27 sec ARIMA(1,1,0)(2,0,0)[12] intercept : AIC=2954.804, Time=11.51 sec ARIMA(3,1,0)(2,0,0)[12] intercept : AIC=2914.414, Time=20.58 sec ARIMA(3,1,2)(2,0,0)[12] intercept : AIC=2915.331, Time=25.20 sec ARIMA(2,1,1)(2,0,0)[12] : AIC=2908.221, Time=12.12 sec ARIMA(2,1,1)(1,0,0)[12] : AIC=2909.011, Time=2.81 sec ARIMA(2,1,1)(2,0,1)[12] : AIC=2910.144, Time=10.88 sec ARIMA(2,1,1)(1,0,1)[12] : AIC=2908.093, Time=2.31 sec ARIMA(2,1,1)(0,0,1)[12] : AIC=2933.343, Time=2.51 sec ARIMA(2,1,1)(1,0,2)[12] : AIC=2910.039, Time=10.76 sec ARIMA(2,1,1)(0,0,0)[12] : AIC=2980.096, Time=0.15 sec ARIMA(2,1,1)(0,0,2)[12] : AIC=2921.090, Time=8.93 sec ARIMA(2,1,1)(2,0,2)[12] : AIC=2912.081, Time=11.93 sec ARIMA(1,1,1)(1,0,1)[12] : AIC=2915.531, Time=2.08 sec ARIMA(2,1,0)(1,0,1)[12] : AIC=2925.551, Time=2.19 sec ARIMA(3,1,1)(1,0,1)[12] : AIC=2911.034, Time=2.70 sec ARIMA(2,1,2)(1,0,1)[12] : AIC=2913.397, Time=2.96 sec ARIMA(1,1,0)(1,0,1)[12] : AIC=2952.580, Time=1.43 sec ARIMA(1,1,2)(1,0,1)[12] : AIC=2922.527, Time=2.51 sec ARIMA(3,1,0)(1,0,1)[12] : AIC=2912.590, Time=2.99 sec ARIMA(3,1,2)(1,0,1)[12] : AIC=2913.867, Time=3.23 sec Best model: ARIMA(2,1,1)(1,0,1)[12] Total fit time: 279.518 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=5, 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:** ( 4 minutes 39.622 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 `_