Example #1
0
Train22=df22[1:424]
Test22=df22[424:len(df22)]

model=pm.auto_arima(Train22['Price'],m=12,seasonal=True,start_q=0,star_p=0,max_order=5,error_action='ignore',stepwise=True,trace=True)


# In[63]:


model.summary()


# In[64]:


model.plot_diagnostics()


# In[76]:


prediction=pd.DataFrame(model.predict(n_periods=423),index=Test22.index)
prediction.columns=['predicted_sales']


# In[77]:


prediction

Example #2
0
model = pm.auto_arima(df.value, start_p=1, start_q=1,
                      test='adf',       # use adftest to find optimal 'd'
                      max_p=3, max_q=3, # maximum p and q
                      m=1,              # frequency of series
                      d=None,           # let model determine 'd'
                      seasonal=False,   # No Seasonality
                      start_P=0,
                      D=0,
                      trace=True,
                      error_action='ignore',
                      suppress_warnings=True,
                      stepwise=True)

print(model.summary())

model.plot_diagnostics(figsize=(7,5))
plt.show()

# Top left: The residual errors seem to fluctuate around a mean of zero and have a uniform variance.
#
# Top Right: The density plot suggest normal distribution with mean zero.
#
# Bottom left: All the dots should fall perfectly in line with the red line.
# Any significant deviations would imply the distribution is skewed.
#
# Bottom Right: The Correlogram, aka, ACF plot shows the residual errors are not autocorrelated.
# Any autocorrelation would imply that there is some pattern in the residual errors which are not explained in the model.
# So you will need to look for more X’s (predictors) to the model.

# Forecast
n_periods = 24