霍尔特冬季模型的预测

问题描述 投票:0回答:1
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.holtwinters import ExponentialSmoothing

df =pd.read_csv(r"C:\Users\USER\PycharmProjects\mysqlconnection\mul.csv",
                 index_col='finalYears')

)
df.index.freq = 'M'
train, test = df.iloc[:20, 0], df.iloc[20:, 0]
model = ExponentialSmoothing(train, seasonal='mul', seasonal_periods=4).fit()
pred = model.predict(start=test.index[0], end=test.index[-1])

plt.plot(train.index, train, label='Train')
plt.plot(test.index, test, label='Test')
plt.plot(pred.index, pred, label='Holt-Winters')
plt.legend(loc='best')

我尝试使用霍尔特-冬天模型进行预测,如上所示,但我不断收到此错误。发生在pred行的错误说:“'start参数无法与与数据索引相关的位置匹配。” ,我要如何处理此错误?

这是我的数据。我将数据分为一年的季度1

python time-series statsmodels forecasting holtwinters
1个回答
0
投票
here起,看来开始,结束必须是int,str或日期时间。如果我这样做
© www.soinside.com 2019 - 2024. All rights reserved.