Statsmodels ETSModel get_prediction 遇到错误

Statsmodels ETSModel get_prediction encounters error

我正在尝试通过 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:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\exponential_smoothing\ets.py", line 2078, in get_prediction
    **simulate_kwargs,

  File "C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tsa\exponential_smoothing\ets.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 转发。