我正在尝试在 python 中使用 HoltWinters 指数平滑,但我得到的结果与我在 R 中使用预测 holt 时得到的结果不同。
在 R 中:
library(forecast)
data_train <- c(0.3990852, 1.8837862, 2.3551793, 3.0099617, 3.4650170,
4.6327859, 3.7989490, 1.2654134, 3.3170017, 4.7559544,
2.7958632, 2.8002729, 3.9480264, 3.0497512)
y_hat <- holt(data_train, h=6)$mean
print(y_hat)
[1] 4.316603 4.483438 4.650274 4.817109 4.983944 5.150779
在蟒蛇中:
import numpy as np
from statsmodels.tsa.holtwinters import ExponentialSmoothing, Holt
data_train = np.array((0.3990852, 1.8837862, 2.3551793, 3.0099617, 3.4650170,
4.6327859, 3.7989490, 1.2654134, 3.3170017, 4.7559544,
2.7958632, 2.8002729, 3.9480264, 3.0497512))
model = ExponentialSmoothing(data_train).fit()
y_hat = model.predict(start=15, end=20)
print(y_hat)
[3.2521686 3.2521686 3.2521686 3.2521686 3.2521686 3.2521686]
fit1 = Holt(data_train).fit()
y_hat = fit1.forecast(6)
print(y_hat)
[3.23339397 3.21157785 3.18976174 3.16794562 3.1461295 3.12431338]
谁能告诉我为什么我在 R 与 python 中得到如此不同的结果?