平均绝对误差
在使用模型进行预测之前,您当然想知道预测的准确度。平均绝对误差(MAE)是一个很好的统计量。它等于您的预测值与真实值之间差值的平均数。
在本练习中,您将为拟合到地震时间序列的 ARMA(1,1) 模型计算 MAE。
numpy 已作为 np 导入到您的环境中,地震时间序列已以 earthquake 的名称提供给您。
本练习是课程的一部分
Python 中的 ARIMA 模型
练习说明
- 使用
np函数计算results对象.resid属性的平均绝对误差(MAE)。 - 打印 MAE。
- 使用 DataFrame 的
.plot()方法(无需传入参数)绘制earthquake时间序列。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fit model
model = ARIMA(earthquake, order=(1,0,1))
results = model.fit()
# Calculate the mean absolute error from residuals
mae = ____
# Print mean absolute error
print(____)
# Make plot of time series for comparison
____
plt.show()