開始使用免費開始

季節性分解

在上一個練習中,你透過視覺檢查與自相關圖,一起找出了交通資料中的重複模式。

現在你要把這些資料進一步拆解成各個組成部分。

traffic 已為你載入完成。

本練習屬於課程

使用 Python 分析 IoT 資料

檢視課程

練習說明

  • sm 匯入 statsmodels.api
  • 對 DataFrame traffic 中時間序列欄位 "vehicles" 執行季節性分解,並將結果指定給 res
  • 在畫面上列印季節性組成(seasonal component)。
  • 繪製時間序列分解的結果。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import modules
____

# Perform decompositon 
res = sm.tsa.____(____[____])

# Print the seasonal component
____

# Plot the result
____

# Show the plot
plt.show()
編輯並執行程式碼