# > set.seed(123) # > abc <- rnorm(50, 5, 1) abc = np.array([ 4.439524, 4.769823, 6.558708, 5.070508, 5.129288, 6.715065, 5.460916, 3.734939, 4.313147, 4.554338, 6.224082, 5.359814, 5.400771, 5.110683, 4.444159, 6.786913, 5.497850, 3.033383, 5.701356, 4.527209, 3.932176, 4.782025, 3.973996, 4.271109, 4.374961, 3.313307, 5.837787, 5.153373, 3.861863, 6.253815, 5.426464, 4.704929, 5.895126, 5.878133, 5.821581, 5.688640, 5.553918, 4.938088, 4.694037, 4.619529, 4.305293, 4.792083, 3.734604, 7.168956, 6.207962, 3.876891, 4.597115, 4.533345, 5.779965, 4.916631 ]) wineind = load_wineind() lynx = load_lynx() def test_basic_arima(): arima = ARIMA(order=(0, 0, 0), trend='c', suppress_warnings=True) preds = arima.fit_predict(y) # fit/predict for coverage # test some of the attrs assert_almost_equal(arima.aic(), 11.201308403566909, decimal=5) assert_almost_equal(arima.aicc(), 11.74676, decimal=5) assert_almost_equal(arima.bic(), 13.639060053303311, decimal=5) # get predictions expected_preds = np.array([ 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876, 0.44079876
.. raw:: html <br/> """ print(__doc__) # Author: Taylor Smith <*****@*****.**> from pyramid.datasets import load_lynx from pyramid.arima import auto_arima import matplotlib.pyplot as plt import numpy as np # ############################################################################# # Load the data and split it into separate pieces data = load_lynx() train, test = data[:100], data[100:] # ############################################################################# # Fit with some validation (cv) samples arima = auto_arima(train, start_p=1, start_q=1, d=0, max_p=5, max_q=5, out_of_sample_size=10, suppress_warnings=True, stepwise=True, error_action='ignore')
error_action='ignore', # don't want to know if an order does not work suppress_warnings=True, # don't want convergence warnings stepwise=True) # set to stepwise stepwise_fit.summary() from pyramid.arima import auto_arima from pyramid.datasets import load_lynx import numpy as np # For serialization: from sklearn.externals import joblib import pickle # Load data and fit a model y = load_lynx() arima = auto_arima(y, seasonal=True) # Serialize with Pickle with open('arima.pkl', 'wb') as pkl: pickle.dump(arima, pkl) # You can still make predictions from the model at this point arima.predict(n_periods=5) # Now read it back and make a prediction with open('arima.pkl', 'rb') as pkl: pickle_preds = pickle.load(pkl).predict(n_periods=5) # Or maybe joblib tickles your fancy joblib.dump(arima, 'arima.pkl')