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')
如上所示,我尝试使用 holt-winters 模型进行预测,但我不断收到此错误。
错误发生在 pred 行表示“'start
参数无法与与数据索引相关的位置匹配。” ,我想如何处理这个错误?
这是我的数据。我将数据分组到一年的季度 1