我正在尝试实现 statsmodel 包中的预测功能
prediction = results.predict(start=1,end=len(test),exog=test)
输入、测试和输出预测的日期不一致。前者为2012年1月4日至2012年7月25日,后者为2013年4月26日至2013年11月13日。部分困难在于我没有完全重复的频率 - 我有每日值,不包括周末和假期。设置索引的适当方法是什么?
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