As a newbie, I am trying to implement the forecast using the auto Arima model. After searching, I found this site illustrates the usage and the hyperparameters used in the model. However, when I tried to forecast, the model gave me an array of constants.
Please advise if I asked in the wrong place. Thanks.
The data is a simple 29 days data:
daily_infect = [ 15, 11, 21, 25, 32, 186, 204, 334, 242, 274, 294, 315, 722,
453, 594, 536, 640, 672, 557, 489, 358, 351, 330, 548, 582, 474,
506, 325, 214]
Here is the code:
# reference: https://alkaline-ml.com/pmdarima/modules/generated/pmdarima.arima.auto_arima.html
import pmdarima as pm
model = pm.auto_arima(daily_infect,
start_p=2, start_q=2, # default=2
test='kpss', # default=kpss
max_p=5, # default=5
max_q=2, # default=2
m=1, # Note that if m == 1 (i.e., is non-seasonal)
d=None, # If None (by default), the value will automatically be selected based on the results of the test
seasonal=False, # No Seasonality
start_P=1, # default=1
D=None, # The order of the seasonal differencing. If None (by default, the value will automatically be selected based on the results of the seasonal_test
trace=True,
error_action='warn', # default=warn
stepwise=True) # The stepwise algorithm can be significantly faster than fitting all (or a random subset of) hyper-parameter combinations and is less likely to over-fit the model.
print(model.summary())
I ran the diagnose. It seems okay
model.plot_diagnostics(figsize=(15,8))
plt.show()
Here is the forecast code:
# Forecast
n_days = 10
fc = model.predict(n_periods=n_days)
index_of_fc = np.arange(len(daily_infect), len(daily_infect)+n_days)
# make series for plotting purpose
fc_series = pd.Series(fc, index=index_of_fc)
# Plot
fig, ax = plt.subplots(figsize=(15,9))
ax.plot(daily_infect)
ax.plot(fc_series, color='red')
ax.set_title("Final Forecast")
ax.figure.autofmt_xdate()
plt.show()
What I've tried is to change some parameters back to default, but no luck. Is there's anything I can improve? Thanks.