Time Series Forecasting

ML forecasting trend seasonality

Data with a clock attached

A time series is a sequence of values recorded in order — monthly sales, daily temperature, hourly traffic. The order matters: unlike a normal train–test split, you can't shuffle it, because tomorrow depends on today. Forecasting means using the past to predict the values that come next.

Trend the slow drift

The long-run direction — gradually rising, falling, or flat.

Seasonality the repeating cycle

A pattern that repeats on a fixed period — every 12 months, every 7 days.

Noise the leftover wiggle

Random variation that no model can or should fit. What's left after trend and season are removed.

Pull it apart, then project it forward

A classic first step is decomposition: split the messy line into trend + seasonality + noise. Once you understand those pieces, you slide a window across the history to learn the pattern and extend it into the future.

How models actually forecast

Sliding window lag features

Turn the series into a supervised problem: use the last k values as features to predict the next one. Then any regressor — even XGBoost — can forecast.

Classical models ARIMA, ETS

Statistical methods that model trend and seasonality directly. Strong, interpretable baselines.

Deep models RNN / LSTM

For long, complex sequences, LSTMs and transformers can capture patterns a window of lags misses.

Validate by time, not by random split

Never shuffle a time series into train/test. Always train on the past and test on the future (a "rolling" or "expanding" window). A random split leaks tomorrow into today and gives a fantasy score.