我想使用Python的statsmodels.api.tsa.get_forcast来预测样本中的数据,这是我的代码:
mod=sm.tsa.SARIMAX(hs300['Close'],order=(2,1,2),seasonal_order=(2,1,2,12),enforce_stationarity=False,enforce_invertibility=False)
result=mod.fit()
pred=result.get_forcast(20)
我想要获取样本之外的 future 20 天的数据,这是我的错误:
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
我该如何解决这个问题?我找到了这个函数的文档,但是这个文件没有给我足够的这个函数的信息:
get_forecast(steps=1, **kwargs) method of statsmodels.tsa.statespace.sarimax.SARIMAXResults instance
Out-of-sample forecasts
Parameters
----------
steps : int, str, or datetime, optional
If an integer, the number of steps to forecast from the end of the
sample. Can also be a date string to parse or a datetime type.
However, if the dates index does not have a fixed frequency, steps
must be an integer. Default
**kwargs
Additional arguments may required for forecasting beyond the end
of the sample. See `FilterResults.predict` for more details.
没有这个函数的例子,谁能给个这个函数的实例吗?
最佳答案
请尝试“result.predicted_mean”。这对我有用。 如果您执行“print(type(result))”,您可能会获得有关 PredictionResults 对象的更多信息。 我希望这会有所帮助。
关于python - statsmodels.api.tsa.get_forcast 的参数是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49239727/