簡體   English   中英

訓練 ARIMA 來預測趨勢

[英]Training ARIMA to forecast the trend

我正在嘗試使用 ARIMA 預測趨勢。 不幸的是,我得到的輸出與預期的輸出大不相同(訓練和測試數據的行為非常相似)並且表明整個訓練數據集好像……沒用?

df = pd.read_csv('data.csv')
df.index = pd.DatetimeIndex(df.index).to_period('D')

#data from 1/1/2016 to 31/12/2018
train = df.loc[:'2018-12-31']
test = df.loc['2019-01-01':]

model = auto_arima(train, start_p=1, start_q=1,
                   max_p=3, max_q=3, m=7,
                   start_P=0, seasonal=True,
                   d=1, D=1, trace=True,
                   error_action='ignore',
                   suppress_warnings=True,
                   stepwise=True)

model.aic()
model.fit(train)
ffforecast = model.predict(n_periods=len(test))
ffforecast = pd.DataFrame(fforecast,
                               index=test.index,
                               columns=['prediction'])
pd.concat([test, fforecast], axis=1).plot()
pyplot.show()

在此處輸入圖片說明

完整代碼: https : //pastebin.com/huer62cM

csv: https://filebin.net/rlvm3hrjetlovd64/newbikes6years.csv?t=nt3slw3y

您為模型使用了一組錯誤的參數。 看起來您從不同的數據集中復制/粘貼了一個示例,但它對您不起作用。

我會建議這樣的:

model = auto_arima(train, error_action='ignore', trace=True, suppress_warnings=True,seasonal=True, maxiter=10, m=7)

根據此輸出,您可以在閱讀參數並了解它們的作用后返回並細化參數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM