Seasonal Decomposition in Python — ELI5
Imagine you blend a fruit smoothie. It tastes great, but you cannot tell how much banana, strawberry, or yogurt is in there just by looking at the glass.
Seasonal decomposition is like un-blending a smoothie. You take a messy line of numbers — like daily ice cream sales over three years — and pull it apart into three clean ingredients.
The first ingredient is the trend. Forget the wiggles and just ask: are sales generally going up, going down, or staying flat over the years? This is the slow, big-picture movement.
The second ingredient is the seasonal pattern. This is the part that repeats like clockwork. Ice cream sales go up every summer and down every winter. That up-down-up-down cycle is the seasonal pattern.
The third ingredient is the leftovers — the noise. After you remove the trend and the seasonal pattern, whatever is left is the random stuff that no pattern explains. Maybe one Tuesday in March had unusually high sales because of a freak heatwave. That is noise.
Python can do this separation in just a few lines of code. You give it the numbers and tell it how long the seasonal cycle is (12 months for yearly patterns, 7 days for weekly patterns), and it spits out three separate charts — one for each ingredient.
Why bother? Because mixed together, the data is confusing. Separated, you can ask useful questions. Is the trend slowing down? Is the seasonal pattern getting stronger? Are the leftovers getting noisier?
The one thing to remember: Seasonal decomposition separates messy time data into three understandable parts — the overall direction, the repeating cycle, and the unexplained leftovers.
See Also
- Python Arima Forecasting How ARIMA models use patterns in past numbers to predict the future, explained like a bedtime story.
- Python Autocorrelation Analysis How today's number is connected to yesterday's, and why that connection is the secret weapon of time series analysis.
- Python Exponential Smoothing How exponential smoothing weighs recent events more heavily to predict what happens next, like trusting fresh memories more than old ones.
- Python Multivariate Time Series Why tracking multiple things at once gives you better predictions than tracking each one alone.
- Python Prophet Forecasting How Facebook's Prophet tool predicts the future by breaking data into easy-to-understand pieces.