python - statsmodels.api.tsa.get_forcast 的参数是什么?

标签 python python-3.x statsmodels

我想使用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/

相关文章:

Python3 HTMLTestRunner 不生成报告

python - 不明白为什么这段代码会引发 EOF 错误

python - StatsModels 的置信区间和预测区间

python - Statsmodels ARIMA - 使用 predict() 和 forecast() 的不同结果

python - 如何通过 HTTP 响应从 Google App Engine 上的 Python 数据存储中检索数据

Python-numpy : 'dimension dependent indexing'

python - 计算 N 个样本和聚类质心之间的平方欧氏距离的最有效方法是什么?

python - 季节分解

python - 在Python BeautifulSoup4中,如何提取这样的特殊文本

python - 如何根据特定列表计算频率?