我正在通过遵循本教程来创建简单的指数平滑模型:https://towardsdatascience.com/time-series-in-python-exponential-smoothing-and-arima-processes-2c67f2a52788
但是遇到了我不明白的问题。我有一个非常简单的熊猫数据框,名为time_series
,具有每日日期时间索引,该值代表当天就诊的人数在20到100之间。它看起来像这样:
patients
Date
2015-01-04 49
2015-01-05 51
2015-01-06 48
2015-01-07 30
2015-01-08 27
但是,在以下代码中运行fit1
行时却收到错误,该代码是我为构建到SES模型而创建的。要构建的代码如下:
train, test = train_test_split(time_series, test_size=0.30, shuffle=False)
model = SimpleExpSmoothing(np.asarray(train['patients']))
model._index = pd.to_datetime(train.index)
fit1 = model.fit()
pred1 = fit1.forecast(9)
fit2 = model.fit(smoothing_level=.2)
pred2 = fit2.forecast(9)
fit3 = model.fit(smoothing_level=.5)
pred3 = fit3.forecast(9)
错误是以下错误,我检查后发现很奇怪,并且训练和测试均不包含空值:
TypeError: unsupported operand type(s) for +: 'Timestamp' and 'NoneType'
有人知道为什么会这样吗?
非常感谢。
您终于得到答案了吗?我有同样的问题吗?