我试图绘制我的实际时间序列值和预测值,但它给了我这个错误:
ValueError:视图限制最小值-36816.95989583333小于1并且是无效的Matplotlib日期值.如果将非日期时间值传递给具有日期时间单位的轴,则通常会发生这种情况
我正在使用statsmodels
适合数据的arima模型.
这是我的数据样本:
datetime value
2017-01-01 00:00:00 10.18
2017-01-01 00:15:00 10.2
2017-01-01 00:30:00 10.32
2017-01-01 00:45:00 10.16
2017-01-01 01:00:00 9.93
2017-01-01 01:15:00 9.77
2017-01-01 01:30:00 9.47
2017-01-01 01:45:00 9.08
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
mod = sm.tsa.statespace.SARIMAX(
subset,
order=(1, 1, 1),
seasonal_order=(1, 1, 1, 12),
enforce_stationarity=False,
enforce_invertibility=False
)
results = mod.fit()
pred_uc = results.get_forecast(steps=500)
pred_ci = pred_uc.conf_int(alpha = 0.05)
# Plot
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(1, 1, 1)
ax.plot(subset,color = "blue")
ax.plot(pred_uc.predicted_mean, color="black", alpha=0.5, label='SARIMAX')
plt.show()
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?