我正试图通过StatsModels ETSModel从Holt-Winters时间序列模型中获得预测区间。有人能帮我弄清楚出了什么问题吗?
fit1 = ETSModel(x_train, seasonal_periods=7, trend='add', seasonal='mul', damped_trend=True).fit()
fcst = fit1.get_prediction(start=current_date, end=current_date + np.timedelta64(6,'D'))
我得到以下错误:
File "C:ProgramDataAnaconda3libsite-packagesstatsmodelstsaexponential_smoothingets.py", line 2078, in get_prediction
**simulate_kwargs,
File "C:ProgramDataAnaconda3libsite-packagesstatsmodelstsaexponential_smoothingets.py", line 2234, in __init__
start : (end + 1)
ValueError: could not broadcast input array from shape (0) into shape (7)
这是输入:
x_train
Out[24]:
ds
2020-08-04 1027.0
2020-08-05 1813.0
2020-08-06 2157.0
2020-08-07 3070.0
2020-08-08 2968.0
2020-08-09 2083.0
2020-08-10 1762.0
2020-08-11 1755.0
2020-08-12 1788.0
2020-08-13 2266.0
2020-08-14 3272.0
2020-08-15 2768.0
2020-08-16 1869.0
2020-08-17 1940.0
2020-08-18 1673.0
2020-08-19 1821.0
2020-08-20 2293.0
2020-08-21 2802.0
2020-08-22 2604.0
2020-08-23 1843.0
2020-08-24 1758.0
2020-08-25 1393.0
2020-08-26 1612.0
2020-08-27 2165.0
2020-08-28 2898.0
2020-08-29 2471.0
2020-08-30 2297.0
Freq: D, dtype: float64
current_date
Out[25]: numpy.datetime64('2020-09-01')
如果开始日期在数据集结束之后,这看起来像是get_prediction
的错误。我建议你在https://github.com/statsmodels/statsmodels/issues/new?template=bug_report.md.
与此同时,您似乎需要将start
设置为数据集中的最后一个日期(例如,在您给出的示例中为2020-08-30(,然后手动将结果子集设置为仅来自current_date
转发。