ARIMA Models in Python
James Fulton
Climate informatics researcher
import pmdarima as pm
results = pm.auto_arima(df)
Performing stepwise search to minimize aic
ARIMA(2,0,2)(1,1,1)[12] intercept : AIC=inf, Time=3.33 sec
ARIMA(0,0,0)(0,1,0)[12] intercept : AIC=2648.467, Time=0.062 sec
ARIMA(1,0,0)(1,1,0)[12] intercept : AIC=2279.986, Time=1.171 sec
...
ARIMA(3,0,3)(1,1,1)[12] intercept : AIC=2173.508, Time=12.487 sec
ARIMA(3,0,3)(0,1,0)[12] intercept : AIC=2297.305, Time=2.087 sec
Best model: ARIMA(3,0,3)(1,1,1)[12]
Total fit time: 245.812 seconds
print(results.summary())
results.plot_diagnostics()
results = pm.auto_arima( df, # data
d=0, # non-seasonal difference order
start_p=1, # initial guess for p start_q=1, # initial guess for q
max_p=3, # max value of p to test max_q=3, # max value of q to test )
results = pm.auto_arima( df, # data ... , # non-seasonal arguments seasonal=True, # is the time series seasonal
m=7, # the seasonal period
D=1, # seasonal difference order
start_P=1, # initial guess for P start_Q=1, # initial guess for Q
max_P=2, # max value of P to test max_Q=2, # max value of Q to test )
results = pm.auto_arima( df, # data ... , # model order parameters
information_criterion='aic', # used to select best model
trace=True, # print results whilst training
error_action='ignore', # ignore orders that don't work
stepwise=True, # apply intelligent order search )
# Import
import joblib
# Select a filepath
filepath ='localpath/great_model.pkl'
# Save model to filepath
joblib.dump(model_results_object, filepath)
# Select a filepath
filepath ='localpath/great_model.pkl'
# Load model object from filepath
model_results_object = joblib.load(filepath)
# Add new observations and update parameters
model_results_object.update(df_new)
ARIMA Models in Python