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