python ValueError:Start必须是日期.得到2016-01-01 | 2016-01-01 00:00:00

gol*_*ggy 8 python statsmodels

我正在使用statsmodels.tsa.statespace.sarimax进行预测.这是我的代码

pprint(list(rolmean_df.index)[0])
>> datetime.date(2015, 5, 19)

mod = sm.tsa.statespace.SARIMAX(rolmean_df['IC_10_diff'], trend='n', order=(2,1,2))
results = mod.fit()
s = results.get_prediction(start = pd.to_datetime('2016-01-01').date(), dynamic= False)
>> ValueError: Start must be in dates. Got 2016-01-01 | 2016-01-01 00:00:00
Run Code Online (Sandbox Code Playgroud)

我不确定我的"开始"格式是否错误或其他什么不起作用.

小智 10

来自doc:http: //www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAXResults.html

  • get_forecast([steps]) 样本外预测
  • get_prediction([start,end,dynamic,exog])样本内预测和样本外预测

所以,"开始必须在日期"意味着开始应该在您的数据集中.

如果要将模型用于forecase,请使用get_forecast().