使用 Python 視覺化時間序列資料
Thomas Vincent
Head of Data Science, Getty Images
t_1、t_2、t_3、...)與其落後 3 個時間點的值(t_4、t_5、t_6、...)之間的相關性
statsmodels是一個 Python 模組,提供多種統計模型的估計類別與函式,也可進行統計檢定與資料探索。
import matplotlib.pyplot as plt
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_acf(co2_levels['co2'], lags=40)
plt.show()

order 3 的偏自相關函式會回傳時間序列(t1、t2、t3、...)與其落後 3 個時間點(t4、t5、t6、...)的相關性,但會先移除落後 1 與 2 的所有影響import matplotlib.pyplot as plt
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_pacf(co2_levels['co2'], lags=40)
plt.show()

使用 Python 視覺化時間序列資料