Autocorrelation & Stationarity
Useful for time-series forecasting.
1. Plain English Intuition
Autocorrelation measures how correlated a signal is with a time-lagged copy of itself (e.g. today’s temperature vs yesterday’s). Stationarity means the statistical properties of the series (mean, variance, autocorrelation) do not change over time. If a series has an upward trend or growing seasonality, it is non-stationary; machine learning models struggle because the test data distribution drifts away from training.
2. Where It Appears in ML & Deep Learning
- 1Time-series forecasting with ARIMA, Prophet, and temporal deep learning models
- 2Detecting seasonality and repeating cycles in business metrics
- 3Differencing and detrending data before feeding to regression models
- 4Financial volatility modeling
3. Inputs, Outputs, Shapes & Assumptions
4. What Can Go Wrong (Gotchas & Failures)
Spurious regression: Training on two non-stationary upward-trending lines creates apparent strong correlation with zero real relationship.
Predicting future values without accounting for structural trend breaks.
5. Python in Practice
Engineered using: statsmodels.tsa.stattools.acf, statsmodels.tsa.stattools.adfuller
import numpy as np
# Non-stationary series: Trend + Noise
t = np.arange(100)
non_stationary = 0.5 * t + np.random.randn(100)
# First difference: x_t - x_{t-1} converts it to stationary noise
stationary = np.diff(non_stationary)
print(f"Original series variance: {np.var(non_stationary):.2f}")
print(f"Differenced stationary series variance: {np.var(stationary):.2f}")Fast Study Loop
Complete these 3 steps to mark this topic understood:
Curated Video Lesson
Autoregressive and Moving Average Models (ARIMA)
Watch on YouTube