我正在尝试对我的数据集 FinalModel 执行 Holt-Winters 指数平滑处理,该数据集除了其他列之外还Date
具有索引和Crimecount
列。我只想预测该CrimeCount
列,但出现以下错误:
ValueError: Buffer dtype mismatch, expected 'double' but got 'long long'
我的代码:
df = FinalModel.copy()
train, test = FinalModel.iloc[:85, 18], df.iloc[85:, 18]
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.holtwinters import ExponentialSmoothing
df.index.freq = 'MS'
model = ExponentialSmoothing(train.astype(np.int64), seasonal='mul', seasonal_periods=12).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')