繪製一步預測
現在你已經對 Amazon 股票做出預測,該把這些預測畫出來看看效果了。
你在可用資料的最近 30 天上進行了預測,並且每次只往前預測 1 天。透過評估這些一步預測,你可以判斷模型在預測隔天(你尚不知道答案)時的表現如何。
lower_limits、upper_limits 和 amazon 這些 DataFrame,以及你在上一個練習中建立的平均預測 mean_forecast,都已經在你的環境中可以使用。
本練習屬於課程
Python 中的 ARIMA 模型
練習說明
- 繪製
amazon資料,使用amazon.index作為 x 座標。 - 以相同方式繪製
mean_forecast的預測,使用mean_forecast.index作為 x 座標。 - 在你的信賴區間的
lower_limits與upper_limits之間繪製陰影區域。使用lower_limits的索引作為 x 座標。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# plot the amazon data
plt.plot(____, ____, label='observed')
# plot your mean predictions
plt.plot(____, ____, color='r', label='forecast')
# shade the area between your confidence limits
plt.____(____, ____,
____, color='pink')
# set labels, legends and show plot
plt.xlabel('Date')
plt.ylabel('Amazon Stock Price - Close USD')
plt.legend()
plt.show()