20/22
Time Series Basics · Page 1 of 1

Unique Challenges of Time Series

Time Series Basics

What Makes Time Series Different?

Standard ML assumes independence: Each row is independent. Time Series has temporal dependence: Today's value depends on yesterday's.

Examples:

  • Stock prices: Tomorrow's price influenced by today's
  • Weather: Tomorrow's temp influenced by seasonal patterns
  • Website traffic: Spikes during work hours, dips at night

Autocorrelation

A variable's correlation with its past values.

  • AC at lag-1: Correlation with 1-day-old value
  • AC at lag-7: Correlation with 7-day-old value (weekly pattern)

If AC(lag-7) is high, clear weekly seasonality exists!

Stationarity (Critical!)

A series is stationary if its mean, variance, and autocorrelation don't change over time.

Stationary Series ✓

Mean = constant, variance = constant

  • Example: Deviations from a trend (after differencing)

Non-Stationary Series ✗

Mean or variance changes over time (trend or seasonality)

  • Example: Stock price (always going up/down)

Why it Matters:

Most models (ARIMA) require stationarity! If non-stationary, difference the series:

differenced = series - series.shift(1)
# Now series is stationary

Components of Time Series

Observed = Trend + Seasonal + Residual

Trend: Long-term direction (up/down)
Seasonal: Repeating patterns (daily, weekly, yearly)
Residual: Noise (random fluctuations)

Forecasting Approaches

ARIMA (for univariate stationary series)

AR: Use past values (autoregression)
I: Differencing for stationarity (integration)
MA: Use past errors (moving average)

ARIMA(p, d, q)
p = AR order (how many past values)
d = differencing (how many times to difference)
q = MA order (how many past errors)

LSTM (for complex, non-linear patterns)

Recurrent Neural Networks remember long-term patterns.

  • Pros: Handles non-linear, seasonality, trends automatically
  • Cons: Needs lots of data (1000+ samples)

Prophet (by Facebook)

Decompose + model each component separately.

  • Pros: Intuitive, handles missing data, built-in holidays
  • Cons: Less flexible than ARIMA/LSTM
main.py
Loading...
OUTPUT
Click "Run Code" to execute…