python實(shí)現(xiàn)時間序列自相關(guān)圖(acf)、偏自相關(guān)圖(pacf)教程
自相關(guān)圖是一個平面二維坐標(biāo)懸垂線圖。橫坐標(biāo)表示延遲階數(shù),縱坐標(biāo)表示自相關(guān)系數(shù)
偏自相關(guān)圖跟自相關(guān)圖類似, 橫坐標(biāo)表示延遲階數(shù),縱坐標(biāo)表示偏自相關(guān)系數(shù)
自相關(guān)圖與偏自相關(guān)圖的python代碼實(shí)現(xiàn):
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
plot_acf(b.salesVolume)plot_pacf(b.salesVolume)
可以看到,這個數(shù)據(jù)是偏自相關(guān)系數(shù)拖尾,自相關(guān)系數(shù)截尾的數(shù)據(jù)
補(bǔ)充知識:python 數(shù)據(jù)相關(guān)性可視化
話不多說直接上代碼
import matplotlib.pyplot as pltimport seaborn as snsdata = test_feature.corr() #test_feature => pandas.DataFrame#sns.heatmap(data)plt.show()
效果圖
以上這篇python實(shí)現(xiàn)時間序列自相關(guān)圖(acf)、偏自相關(guān)圖(pacf)教程就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
