Why this matters
Much of the data organisations hold is recorded over time: monthly sales at a provisions shop, weekly maize prices at a market, daily mobile money transaction counts across an agent network, clinic attendance, rainfall. Planning stock, staff and cash depends on forecasting it. Adverts mention forecasting, and sensor and transaction data that arrive over time.
The parts of a time series
Plot the series before anything else. Most series combine:
- Trend: a long term rise or fall, such as growing transaction counts as more people use an agent.
- Seasonality: a pattern that repeats on a fixed calendar, such as maize prices rising in the lean season before harvest, or transactions peaking at month end when salaries arrive.
- Events: festivals, school fees time, public holidays, or a network outage.
- Noise: random variation left over.
statsmodels' seasonal_decompose splits a series into trend, seasonal and leftover parts so you can see each.
Start with simple forecasts
Two simple methods are surprisingly hard to beat and make good baselines: