当前位置:网站首页>Machine learning notes - Introduction to autocorrelation and partial autocorrelation
Machine learning notes - Introduction to autocorrelation and partial autocorrelation
2022-06-30 12:50:00 【Sit and watch the clouds rise】
1、 summary
Autocorrelation and partial autocorrelation graphs are widely used in time series analysis and prediction .
These charts graphically summarize the strength of the relationship with observations in the time series and observations in previous time steps . For beginners of time series prediction , The difference between autocorrelation and partial autocorrelation can be confusing .
We will learn how to use Python Calculate and draw autocorrelation and partial correlation diagrams . And understand the following
How to draw and view the autocorrelation function of time series .
How to plot and view the partial autocorrelation function of time series .
Difference between autocorrelation function and partial autocorrelation function used in time series analysis .
2、 Minimum daily temperature data set
This data set describes the city of Melbourne, Australia 10 year (1981-1990 year ) Minimum daily temperature of .
The unit is centigrade , Yes 3,650 An observation . The data source is Australian meteorological agency .
Dataset download address
link :https://pan.baidu.com/s/19G9YsOKtRDXNYAKdOwBq6A
Extraction code :atebNow load the minimum daily temperature and plot the time series .
from pandas import read_csv
from matplotlib import pyplot
series = read_csv('daily-minimum-temperatures.csv', header=0, index_col=0)
series.plot()
pyplot.show()Run this example to load the dataset as Pandas Series and create a line graph of the time series .

3、 Correlation and autocorrelation
Correlation summarizes the strength of the relationship between two variables . We can assume that the distribution of each variable is Gaussian ( A bell curve ) Distribution . If that's the case , We can use Pearson correlation coefficient to summarize the correlation between variables .
Pearson The correlation coefficient is between -1 and 1 Number between , Describe negative or positive correlation respectively . A value of zero indicates no correlation .
We can calculate the correlation between time series observations and previous time step observations , It is called hysteresis . Because the correlation of time series observations is calculated using the values of previous time series of the same time , So this is called sequence correlation or autocorrelation .
The lag graph of time series autocorrelation is called AutoCorrelation Function, Or acronyms ACF. This graph is sometimes called a correlation graph or an autocorrelation graph .
Here's how to use statsmodels In the library plot_acf() Function to calculate and plot the autocorrelation diagram of the minimum daily temperature .
from pandas import read_csv
from matplotlib import pyplot
from statsmodels.graphics.tsaplots import plot_acf
series = read_csv('daily-minimum-temperatures.csv', header=0, index_col=0)
plot_acf(series)
pyplot.show()Running the example creates a 2D chart , Display edge x The hysteresis value of the shaft and at -1 and 1 Between y Correlation on the axis .
The confidence interval is plotted as a cone . By default , This is set to 95% The confidence interval of , This indicates that correlation values outside this code are likely to be correlations rather than statistical flukes .

By default , All hysteresis values will be printed , This makes the drawing noisy . We can x The number of lags on the shaft is limited to 50, To make the drawing easier to read .

4、 Partial autocorrelation function
Partial autocorrelation is a summary of the relationship between observations in time series and observations in previous time steps , The relationship between intervention and observation is deleted .
The autocorrelation between the observed value and the observed value of the previous time step consists of direct correlation and indirect correlation . These indirect correlations are linear functions of observed correlations , Observe on the intervention time step .
It is these indirect correlations that the partial autocorrelation function attempts to eliminate .
The following example uses statsmodels In the library plot_pacf() The minimum daily temperature data set is calculated and plotted 50 Partial autocorrelation function with time delay .
from pandas import read_csv
from matplotlib import pyplot
from statsmodels.graphics.tsaplots import plot_pacf
series = read_csv('daily-minimum-temperatures.csv', header=0, index_col=0)
plot_pacf(series, lags=50)
pyplot.show()
边栏推荐
- 时空预测2-GCN_LSTM
- 【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
- mqtt-ros模拟发布一个自定义消息类型
- 力扣之螺旋矩阵,一起旋转起来(都能看懂)
- Substrate 源码追新导读: Call调用索引化, 存储层事物化全面完成
- [learn awk in one day] operator
- [one day learning awk] use of built-in variables
- elementui中清除tinymce富文本缓存
- Dqn notes
- [surprised] the download speed of Xunlei is not as fast as that of the virtual machine
猜你喜欢

New function of SuperMap iserver11i -- release and use of legend

Redis-緩存問題

Q-learning notes

【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle

数据仓库建设之确定主题域

【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)

zabbix-server启动失败处理方式
![[MySQL] MySQL installation and configuration](/img/82/8500949734e57e6a1047c4e838f625.png)
[MySQL] MySQL installation and configuration
![[one day learning awk] use of built-in variables](/img/5b/bc1b91804e03dcfd3fe7eae8084eb4.png)
[one day learning awk] use of built-in variables

QT implementation dynamic navigation bar
随机推荐
【OpenGL】OpenGL Examples
论文解读(AGC)《Attributed Graph Clustering via Adaptive Graph Convolution》
Charles打断点修改请求数据&响应数据
你想要的异常知识点都在这里了
Double dqn notes
STM32 移植 RT-Thread 标准版的 FinSH 组件
FlinkSQL自定义UDAF使用的三种方式
FlinkSQL自定义UDTF使用的四种方式
How to use AI technology to optimize the independent station customer service system? Listen to the experts!
LeetCode_栈_中等_227.基本计算器 II(不含括号)
QT implementation dynamic navigation bar
力扣之螺旋矩阵,一起旋转起来(都能看懂)
Apple executives openly "open the connection": Samsung copied the iPhone and only added a large screen
ffmpeg 杂项
ECDSA signature verification in crypt
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
Flink SQL console, group not recognized_ Concat function?
[MySQL] MySQL installation and configuration
JMeter性能测试工作中遇到的问题及剖析,你遇到了几个?
【MySQL】MySQL的安装与配置