.. _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=2915.641, BIC=2939.673, Fit time=0.355 seconds Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3049.597, BIC=3055.604, Fit time=0.012 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 0, 0, 12); AIC=2954.973, BIC=2966.989, Fit time=0.220 seconds Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 0, 1, 12); AIC=2947.014, BIC=2959.029, Fit time=0.246 seconds Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 0, 0, 12); AIC=3047.612, BIC=3050.616, Fit time=0.009 seconds Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 0, 1, 12); AIC=2938.457, BIC=2959.484, Fit time=0.396 seconds Fit ARIMA: order=(2, 1, 2) seasonal_order=(1, 0, 0, 12); AIC=2915.636, BIC=2936.664, Fit time=0.382 seconds Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 0, 0, 12); AIC=2984.606, BIC=3002.630, Fit time=0.118 seconds Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2915.168, BIC=2939.200, Fit time=1.986 seconds Fit ARIMA: order=(2, 1, 2) seasonal_order=(2, 0, 1, 12); AIC=2917.256, BIC=2944.291, Fit time=2.802 seconds Fit ARIMA: order=(1, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2924.379, BIC=2945.407, Fit time=1.822 seconds Fit ARIMA: order=(2, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2911.007, BIC=2932.034, Fit time=2.216 seconds Fit ARIMA: order=(2, 1, 1) seasonal_order=(1, 0, 0, 12); AIC=2911.505, BIC=2929.528, Fit time=0.255 seconds Fit ARIMA: order=(2, 1, 1) seasonal_order=(2, 0, 1, 12); AIC=2912.933, BIC=2936.965, Fit time=3.474 seconds Fit ARIMA: order=(2, 1, 1) seasonal_order=(1, 0, 1, 12); AIC=2911.904, BIC=2932.932, Fit time=0.406 seconds Fit ARIMA: order=(1, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2919.168, BIC=2937.192, Fit time=2.368 seconds Fit ARIMA: order=(2, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2927.636, BIC=2945.660, Fit time=2.311 seconds Fit ARIMA: order=(3, 1, 1) seasonal_order=(2, 0, 0, 12); AIC=2912.748, BIC=2936.780, Fit time=3.085 seconds Fit ARIMA: order=(1, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2954.725, BIC=2969.745, Fit time=1.894 seconds Fit ARIMA: order=(3, 1, 0) seasonal_order=(2, 0, 0, 12); AIC=2914.169, BIC=2935.197, Fit time=3.420 seconds Fit ARIMA: order=(3, 1, 2) seasonal_order=(2, 0, 0, 12); AIC=2915.130, BIC=2942.165, Fit time=4.398 seconds Total fit time: 32.260 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 32.352 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 `_