AI State of the Art
Domains/Séries temporelles/24 min
Section 232

Time Series: What Makes Them Special

Listen as a podcast →

The problem: data where order is everything

Picture a temperature sensor bolted onto a turbine. Every second, it records a number. After a month you have a long column of numbers, and a question: is this turbine about to fail?

That kind of data has a name: a time series. It is a sequence of measurements ordered in time, where the order carries the information. Shuffle the rows of a customer table and you lose nothing; shuffle the points of a temperature curve and you destroy everything, the slow climb that announced the overheating is gone.

Time series are everywhere:

  • Industrial sensors: vibration, pressure, temperature of a machine, sampled every second.
  • Electricity consumption: the demand on a power grid, hour by hour, with its evening peaks.
  • Stock prices: the price of a share, minute by minute.
  • Medical signals: an electrocardiogram (ECG, the recording of the heart's electrical activity), hundreds of points per second.

The four tasks

Almost everything we ask a machine to do with a time series falls into one of four families:

  • Forecasting: guessing how the curve continues. How many yogurts should the supermarket order for next week? This is the flagship task, it drives purchasing, inventory, production.
  • Anomaly detection: spotting the moment the curve stops behaving normally. Is that unusual vibration on the turbine the beginning of a failure?
  • Classification: assigning a whole curve to a category. Is this ECG normal, or does it show an arrhythmia?
  • Imputation: filling in the gaps. A sensor went down between 3 and 5 a.m.; what was the reading most likely doing during that blank?

For forecasting, one word of vocabulary will serve throughout the module: the horizon is how far ahead you are predicting. Forecasting the next hour and forecasting next year are problems of incomparable difficulty, uncertainty compounds at every step, like a rumor that warps a little with each retelling.

Four tasks, one shared foundation

All four tasks rest on the same prerequisite: understanding the structure of the curve, its rhythms, its direction, its habits. That is why the same model families show up in all four, and why this page starts with vocabulary.

One extra word about anomaly detection, because "abnormal" covers three different things:

  • The point anomaly: a value absurd in itself, a thermometer reading 300 °C.
  • The contextual anomaly: an ordinary value, but not at that moment, 20 °C, fine in summer, alarming in January. Impossible to spot without understanding seasonality.
  • The collective anomaly: every point is normal, but their sequence is not, a heart beating at a plausible rate but suddenly with perfect regularity, stripped of its natural variability.

The last two require a model of what should have happened: detecting an anomaly is, at bottom, forecasting normal behavior and measuring the gap.

The domain's vocabulary, in plain language

Four notions are enough to read most of the literature.

Trend: the underlying direction, once the noise is ignored. A growing company's sales climb year after year, that slow slope beneath the wiggles is the trend.

Seasonality: a pattern that repeats at a fixed interval. Electricity consumption has a daily cycle (evening peak), a weekly one (weekend dip) and a yearly one (winter heating). These cycles stack on top of each other.

Autocorrelation: the fact that a value resembles its neighbors in time. The temperature at 3 p.m. looks a lot like the one at 2 p.m., somewhat like yesterday at 3 p.m., and hardly at all like six months ago. That resemblance to the recent past is what makes forecasting possible at all: with zero autocorrelation, the curve would be a lottery draw and nothing could be predicted.

Why the stock market is the worst pupil in the class

Stock prices illustrate the limit: the level of a price is highly autocorrelated (tomorrow's price will be close to today's), but its changes barely are, knowing the share went up today says almost nothing about tomorrow. For good reason: if an exploitable regularity appeared, traders would exploit it at once and make it vanish. Which is why anyone claiming to "predict the market" with a model, however sophisticated, deserves suspicion on principle.

Stationarity: a series is called stationary when its statistical behavior does not change over time, same average level, same size of wiggles, yesterday as tomorrow. The steady hum of an engine at cruising speed is stationary; the revenue of a fast-growing company is not.

Now apply the whole vocabulary in one go to a country's electricity consumption:

  • trend: a slow rise over ten years (population, air conditioning);
  • seasonalities: a peak every evening around 7 p.m., a dip every weekend, a bulge every winter;
  • autocorrelation: strong, demand at 3 p.m. closely resembles demand at 2 p.m.;
  • stationarity: no, the arrival of electric cars or an energy crisis durably shifts the level and the habits.

Four words, and the curve is already half read. That is exactly what the module's methods do, each in its own way.

Four plots of real time series: monthly sales of new one-family houses in the USA, US treasury bill contracts over 100 days, Australian quarterly electricity production, and daily changes in the Google closing stock price.
Four real series, four structures. Top left, strong yearly seasonality in house sales; top right, a downward trend with no seasonality; bottom left, trend and seasonality stacked in electricity production; bottom right, the daily changes of a stock price, no visible structure, the very example of the unpredictable series from the callout above.Source : Forecasting: Principles and Practice (Hyndman and Athanasopoulos), OTexts
Non-stationarity: THE trap of the field

Every forecasting model makes the same bet: the future will resemble the past. A non-stationary series breaks that bet, the level drifts, habits change, a crisis or a regime change hits, and the model keeps forecasting the world as it used to be. This is the number-one cause of failure in practice. A large share of the methods in this module (ARIMA's differencing, the instance normalization of foundation models) are precisely counter-measures to this trap.

Univariate or multivariate

A univariate series tracks a single quantity: just the turbine's temperature. A multivariate series tracks several in parallel, aligned on the same time axis: the temperature, vibration and pressure of that same turbine.

What makes the multivariate case interesting is that the variables talk to each other: the vibration that rises before the temperature may be the true early warning of the failure. A good multivariate model exploits these cross-influences, but it has far more relationships to learn, and a matching risk of hallucinating ones that do not exist.

An in-between case deserves its name: exogenous variables. These are quantities you are not trying to forecast but that help forecast the target: the weather for electricity demand, the promotions calendar for sales, public holidays for traffic. Some are even known in advance (the calendar), a rare luxury: a piece of the future handed to the model for free.

Why evaluation is treacherous

To evaluate an ordinary model, you set aside some examples at random and check against them, the split described in the lesson on data splitting. With a time series, that reflex is a mistake.

The reason: because of autocorrelation, a Tuesday data point "contains" a good part of Monday and Wednesday. If Tuesday sits in the test set while Monday and Wednesday sit in the training set, the model has practically seen the answer. Results will look superb in the lab and mediocre in production. This is data leakage, temporal edition.

The rule is simple and admits no exception: train on the past, test on the future. Cut the series at a date; everything before it is for learning, everything after it is for checking, never mix the two.

In practice this is refined into walk-forward validation: stand at the end of January and forecast February; then move to the end of February and forecast March; and so on. The model is graded on a whole series of dress rehearsals, each respecting the arrow of time, instead of a single cut that might happen to land on an unusually easy or hard month.

The reflex when reading a forecasting paper

Two questions to ask of any paper or dossier announcing impressive numbers: is the test period strictly after the training period? And is the model compared with a naive baseline ("tomorrow = today")? If either answer is missing, the announced performance proves nothing. The next lesson explains why that naive baseline is so hard to beat.

Why the recipes from text do not transfer as-is

Machine learning's recent triumphs come from text and images, so the temptation is to reuse the same recipes. Three differences resist:

  • No dictionary. A text is made of words drawn from a finite vocabulary; a curve is made of arbitrary real numbers (42.7, then 41.3…). Some way of chopping the curve into manageable units has to be invented.
  • No common scale. One series hovers around 5, another around 5 million. A word is the same word in every document; "3,000" means completely different things on a temperature curve and on a revenue curve.
  • No stable world. The meaning of the word "cat" does not drift from one month to the next; the behavior of a series does. The non-stationarity trap, again.
  • No single rhythm. One series is sampled every second, another every month. A model claiming to handle both must cope with time steps of incomparable size, a problem that text, read word after word, simply does not have.

These three obstacles explain the module's plan: the recent solutions only make sense once you have seen what the classical methods already did very well.

The module's plan: the families of methods

FamilyThe idea in one sentenceWhere in the module
Naive baselinesTomorrow = today (or = one week ago); the mandatory point of comparisonClassical methods
Classical statistics (exponential smoothing, ARIMA, Prophet)Decompose the curve into trend + season + remainder, and model each pieceClassical methods
Deep learning (DeepAR, TCN, N-BEATS)Learn patterns across thousands of series at once, instead of fitting each series in isolationDeep learning
Foundation models (TimesFM, Chronos, Moirai)One model pre-trained on huge corpora of curves, forecasting series it has never seenFoundation models

Key takeaways

  1. A time series is a sequence of measurements in which order carries the information; it shows up in industry, energy, finance and medicine.
  2. Four tasks: forecasting, anomaly detection, classification, imputation, all resting on the same reading of the curve's structure.
  3. Four notions: trend (the underlying slope), seasonality (repeating cycles), autocorrelation (the present resembles the recent past, the very thing that makes forecasting possible), stationarity (behavior that does not change over time).
  4. THE trap is non-stationarity: when the past stops resembling the future, any model trained on the past is confidently wrong.
  5. Evaluation must respect time: train on the past, test on the future, never mix, otherwise data leakage and illusory performance.
  6. The module follows the field's history: naive baselines and classical methods, then deep learning, then foundation models.
Check your understanding0 / 5

1. To evaluate a forecasting model, an engineer holds out 20% of the points drawn at random from the series and tests on those. Why is that a mistake?

2. An outdoor thermometer reads 20 °C on 15 January. Each value taken alone is plausible. What kind of anomaly is this, and what does it require?

3. The page calls non-stationarity 'THE trap' of the field. Why that special status?

4. Why does the page advise distrusting anyone who claims to predict the stock market, while granting that a price series is strongly autocorrelated?

5. A model that excels on text is proposed as-is for time series. What difficulty specific to curves does the page emphasize?