A u tocorrelation and Partial a u tocorrelation VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON Thomas Vincent Head of Data Science , Ge � y Images
A u tocorrelation in time series data A u tocorrelation is meas u red as the correlation bet w een a time series and a dela y ed cop y of itself For e x ample , an a u tocorrelation of order 3 ret u rns the correlation bet w een a time series at points ( t_1 , t_2 , t_3 , ...) and its o w n v al u es lagged b y 3 time points , i . e . ( t_4 , t_5 , t_6 , ...) It is u sed to � nd repetiti v e pa � erns or periodic signal in time series VISUALIZING TIME SERIES DATA IN PYTHON
Statsmodels statsmodels is a P y thon mod u le that pro v ides classes and f u nctions for the estimation of man y di � erent statistical models , as w ell as for cond u cting statistical tests , and statistical data e x ploration . VISUALIZING TIME SERIES DATA IN PYTHON
Plotting a u tocorrelations import matplotlib.pyplot as plt from statsmodels.graphics import tsaplots fig = tsaplots.plot_acf(co2_levels['co2'], lags=40) plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
Interpreting a u tocorrelation plots VISUALIZING TIME SERIES DATA IN PYTHON
Partial a u tocorrelation in time series data Contrar y to a u tocorrelation , partial a u tocorrelation remo v es the e � ect of pre v io u s time points For e x ample , a partial a u tocorrelation f u nction of order 3 ret u rns the correlation bet w een o u r time series ( t1 , t2 , t3 , ...) and lagged v al u es of itself b y 3 time points ( t4 , t5 , t6 , ...), b u t onl y a � er remo v ing all e � ects a � rib u table to lags 1 and 2 VISUALIZING TIME SERIES DATA IN PYTHON
Plotting partial a u tocorrelations import matplotlib.pyplot as plt from statsmodels.graphics import tsaplots fig = tsaplots.plot_pacf(co2_levels['co2'], lags=40) plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
Interpreting partial a u tocorrelations plot VISUALIZING TIME SERIES DATA IN PYTHON
Let ' s practice ! VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON
Seasonalit y, trend and noise in time series data VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON Thomas Vincent Head of Data Science , Ge � y Images
Properties of time series VISUALIZING TIME SERIES DATA IN PYTHON
The properties of time series Seasonalit y: does the data displa y a clear periodic pa � ern ? Trend : does the data follo w a consistent u p w ards or do w n w ards slope ? Noise : are there an y o u tlier points or missing v al u es that are not consistent w ith the rest of the data ? VISUALIZING TIME SERIES DATA IN PYTHON
Time series decomposition import statsmodels.api as sm import matplotlib.pyplot as plt from pylab import rcParams rcParams['figure.figsize'] = 11, 9 decomposition = sm.tsa.seasonal_decompose( co2_levels['co2']) fig = decomposition.plot() plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
A plot of time series decomposition on the CO 2 data VISUALIZING TIME SERIES DATA IN PYTHON
E x tracting components from time series decomposition print(dir(decomposition)) ['__class__', '__delattr__', '__dict__', ... 'plot', 'resid', 'seasonal', 'trend'] print(decomposition.seasonal) datestamp 1958-03-29 1.028042 1958-04-05 1.235242 1958-04-12 1.412344 1958-04-19 1.701186 VISUALIZING TIME SERIES DATA IN PYTHON
Seasonalit y component in time series decomp_seasonal = decomposition.seasonal ax = decomp_seasonal.plot(figsize=(14, 2)) ax.set_xlabel('Date') ax.set_ylabel('Seasonality of time series') ax.set_title('Seasonal values of the time series') plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
Seasonalit y component in time series VISUALIZING TIME SERIES DATA IN PYTHON
Trend component in time series decomp_trend = decomposition.trend ax = decomp_trend.plot(figsize=(14, 2)) ax.set_xlabel('Date') ax.set_ylabel('Trend of time series') ax.set_title('Trend values of the time series') plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
Trend component in time series VISUALIZING TIME SERIES DATA IN PYTHON
Noise component in time series decomp_resid = decomp.resid ax = decomp_resid.plot(figsize=(14, 2)) ax.set_xlabel('Date') ax.set_ylabel('Residual of time series') ax.set_title('Residual values of the time series') plt.show() VISUALIZING TIME SERIES DATA IN PYTHON
Noise component in time series VISUALIZING TIME SERIES DATA IN PYTHON
Let ' s practice ! VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON
A re v ie w on w hat y o u ha v e learned so far VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON Thomas Vincent Head of Data Science , Ge � y Images
So far ... Vis u ali z e aggregates of time series data E x tract statistical s u mmaries A u tocorrelation and Partial a u tocorrelation Time series decomposition VISUALIZING TIME SERIES DATA IN PYTHON
The airline dataset VISUALIZING TIME SERIES DATA IN PYTHON
Let ' s anal yz e this data ! VISU AL IZIN G TIME SE R IE S DATA IN P YTH ON
Recommend
More recommend