3
我想實現從statsmodel包statsmodel預測開始和結束指數
prediction = results.predict(start=1,end=len(test),exog=test)
輸入,測試的日期預測功能,輸出預測不一致。前者爲2012年1月4日至2012年7月25日,後者爲4/26/2013至11/13/2013。部分難點在於我沒有完全重複發生的頻率 - 我每天的價值不包括週末和節假日。什麼是設置指數的適當方式?
x = psql.frame_query(query,con=db)
x = x.set_index('date')
train = x[0:len(x)-50]
test = x[len(x)-50:len(x)]
arima = tsa.ARIMA(train['A'], exog=train, order = (2,1,1))
results = arima.fit()
prediction = results.predict(start=test.index[0],end=test.index[-1],exog=test)
我得到的錯誤
There is no frequency for these dates and date 2013-04-26 00:00:00 is not in dates index. Try giving a date that is in the dates index or use an integer
這裏的第一組數據
2013-04-26 -0.9492
2013-04-29 2.2011
...
2013-11-12 0.1178
2013-11-13 2.0449
那麼,整合不起作用?我應該使用datetime對象? – user1802143
我使用代碼編輯了我原來的帖子。請讓我知道我是否應該發佈任何其他相關信息。 – user1802143
整數將工作。查看文檔字符串和郵件列表討論。 – jseabold