[英]Statsmodels package in Python - issues with retrieving out-of-sample prediction of ARIMA model
I'm trying to retrieve an out-of-sample prediction for ARIMA model. 我正在尝试检索ARIMA模型的样本外预测。 However, I constantly receive errors and I'm not sure how should I proceed now:( The code is the following:
但是,我经常收到错误,我不知道我现在该怎么办:(代码如下:
from statsmodels.tsa.arima_model import ARIMA
fit = ARIMA(endog, (1,1,1)).fit()
params = fit.params
forecast = fit.predict(params.all(), start='2015-9-21', end='2016-9-21', typ='levels')
It worked well (ie giving me a result, but not an out-of-sample one...) when I only used 当我只使用时,它运作良好(即给我一个结果,但不是一个非样本的...)
forecast = fit.predict(params.all(), typ='levels')
but when I added "start" and "end" dates (or only "start") it doesn't want to work, I constantly get errors. 但是当我添加“开始”和“结束”日期(或只是“开始”)它不想工作时,我经常会出错。 In case of the first cited chunk of code its: "TypeError: predict() got multiple values for keyword argument 'start'".
在第一个引用的代码块的情况下:“TypeError:predict()得到关键字参数'start'”的多个值。 I also tried with datetime type and it also didn't work.
我也尝试过datetime类型,但也没用。 Can anyone help me with it?
任何人都可以帮助我吗?
I was getting a similar error to the one reported above: 我收到与上面报告的类似的错误:
"AttributeError: 'NoneType' object has no attribute 'get_loc' "
But I realised this was because I was passing an array (or list) without a datetime index, eg if you use pandas dataframes and input it as df.values
, then you drop the time index, and ARMA doesn't have the dates information (so dates is None) which triggers this error. 但我意识到这是因为我传递的数组(或列表)没有日期时间索引,例如,如果您使用pandas数据帧并将其输入为
df.values
,那么您删除时间索引,并且ARMA没有日期信息(因此日期为无)会触发此错误。 I suggest you feed in a pd.DataFrame
or pd.Series
object with a datetime index. 我建议你
pd.Series
带有日期时间索引的pd.DataFrame
或pd.Series
对象。 See also this thread http://pystatsmodels.narkive.com/rhX3T509/arma-predict-throws-attributeerror-with-start-and-end-dates 另请参见此主题http://pystatsmodels.narkive.com/rhX3T509/arma-predict-throws-attributeerror-with-start-and-end-dates
You can use 您可以使用
fit.forecast(steps, exog=None, alpha=0.05)
where steps=365
according to your start
and end
parameter if its on monthly basis. 其中
steps=365
根据您的start
和end
参数(如果是每月)。 Refer to the this answer 请参阅此答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.