Module 2 — Data: turning the world into information
Lesson 5 of 13
Time-series data
Some data has an order.
A temperature measured at 09:00 comes before a temperature measured at 10:00.
Electricity demand at 18:00 follows demand at 17:30.
A stock price today follows yesterday's price.
A robot's current position follows its previous position.
When observations are indexed through time, we call the resulting data a time series.
Examples include:
- electricity demand,
- weather measurements,
- financial prices,
- website traffic,
- heart rate,
- machine vibration,
- population,
- vehicle speed,
- battery state of charge.
Time-series data is different from many ordinary datasets because the order of observations matters.
In a time series, when something happened is part of the information.
A simple time series
Suppose we record electricity demand every hour:
| Time | Demand |
|---|---|
| 08:00 | 28 GW |
| 09:00 | 31 GW |
| 10:00 | 34 GW |
| 11:00 | 35 GW |
| 12:00 | 36 GW |
This dataset contains two important pieces of information:
the values
and:
their order through time
If we randomly rearranged the rows:
| Time | Demand |
|---|---|
| 11:00 | 35 GW |
| 08:00 | 28 GW |
| 12:00 | 36 GW |
| 09:00 | 31 GW |
| 10:00 | 34 GW |
the numerical values would be unchanged.
But the temporal pattern would become much harder to see.
The sequence itself contains information.
Time creates relationships between observations
Suppose electricity demand is:
30 GW at 17:00
and:
31 GW at 17:30
The second observation is probably related to the first.
Demand does not normally forget its previous value and begin again from scratch every half-hour.
Many physical, economic and social systems have memory.
Their current condition depends partly on what happened before.
This creates temporal dependence:
PAST → PRESENT → FUTURE
That dependence is one of the reasons time-series prediction is possible.
Yesterday can tell us something about today
Imagine electricity demand at 18:00 for the previous seven days:
| Day | 18:00 demand |
|---|---|
| Monday | 42 GW |
| Tuesday | 43 GW |
| Wednesday | 42 GW |
| Thursday | 44 GW |
| Friday | 45 GW |
| Saturday | 37 GW |
| Sunday | 35 GW |
If today is another weekday, these historical observations provide useful evidence about what demand might look like at 18:00.
The past does not determine the future.
But recurring temporal patterns allow us to make informed predictions.
This is precisely the bridge through time introduced in Module 1.
Time-series data often contains patterns
Many time series contain several different kinds of structure.
Common examples include:
- trends,
- seasonality,
- cycles,
- sudden events,
- noise.
Understanding these patterns helps us decide what information a model should use.
Trend
A trend is a longer-term tendency for a variable to move in a particular direction.
For example:
| Year | Annual electricity demand |
|---|---|
| 2022 | 280 TWh |
| 2023 | 285 TWh |
| 2024 | 291 TWh |
| 2025 | 298 TWh |
Demand appears to be increasing.
The exact value moves from year to year, but there is an underlying upward direction.
Other examples of trends might include:
- population growth,
- declining battery costs,
- increasing data-centre electricity demand,
- long-term temperature change.
A forecasting model may need to distinguish the long-term trend from shorter-term fluctuations.
Seasonality
A seasonal pattern repeats at predictable intervals.
Electricity demand often has:
- daily patterns,
- weekly patterns,
- annual patterns.
For example:
overnight → low demand
morning → rising demand
evening → high demand
night → falling demand
The pattern repeats roughly every 24 hours.
Retail sales may have strong annual seasonality around Christmas.
Traffic may have weekday commuting patterns.
Heating demand may have winter seasonality.
Seasonality does not necessarily mean seasons of the year.
It means a pattern that repeats at some regular interval.
Multiple seasonal patterns can exist at once
A time series can contain several overlapping patterns.
Electricity demand might depend on:
- time of day,
- day of week,
- season of year.
So demand at:
18:00 on a Monday in January
may behave differently from:
18:00 on a Sunday in July.
These interacting temporal patterns can make forecasting more complicated.
Modern models can learn many of these relationships from sufficiently rich historical data.
Cycles
Some patterns recur but not at perfectly regular intervals.
Economic activity may experience:
- expansion,
- slowdown,
- recession,
- recovery.
These cycles may last different lengths of time.
Weather systems may also exhibit recurring large-scale patterns without following a perfectly fixed calendar.
The distinction between seasonality and cycles is therefore useful:
seasonality → regular timing
cycles → recurring behaviour without perfectly fixed timing
Noise
Not every change represents a meaningful pattern.
Suppose electricity demand varies:
30.1 → 30.4 → 30.2 → 30.5 → 30.3 GW
Some of this variation may be:
- random behaviour,
- measurement noise,
- small unmodelled influences.
We often call unpredictable variation noise.
A central challenge in prediction is distinguishing:
signal
from:
noise
The signal contains relationships that may help us predict the future.
Noise does not.
Events can disrupt patterns
Time-series models often rely on repetition.
But unusual events can break normal patterns.
Examples might include:
- extreme weather,
- strikes,
- sporting events,
- public holidays,
- infrastructure failures,
- pandemics,
- political events.
Suppose historical railway demand follows a stable commuting pattern.
Then widespread remote working changes behaviour.
The old pattern may no longer predict the future well.
This is another example of distribution shift.
The system generating the data has changed.
Lags
A lag refers to a previous value of a variable.
Suppose current electricity demand is:
Demand(t)
Then demand one period earlier is:
Demand(t-1)
and two periods earlier:
Demand(t-2)
These previous values can be used as features for prediction.
For example:
Demand(t-1) + Demand(t-2) → predict Demand(t)
This is a very common idea in time-series forecasting.
The past becomes an input to predicting the next state.
Recent history often matters strongly
Suppose a machine temperature is currently:
80°C
Knowing its temperature five seconds ago may be extremely informative.
Knowing its temperature five years ago probably is not.
The usefulness of historical information often depends on how far back we look.
Recent observations may have strong predictive value.
Older observations may matter less.
But this depends on the system.
Some systems have long memories
Not all systems forget quickly.
Consider a battery.
Its current condition may depend partly on:
- previous charging,
- previous discharging,
- temperature history,
- degradation over many cycles.
Or consider an economy.
Current conditions may reflect decisions and investments made years earlier.
Or a person's health.
Past exposures and behaviours can affect current outcomes.
The relevant history depends on the process being modelled.
The current value may not be enough
Suppose two machines both have a temperature of:
80°C
Machine A has followed:
60 → 65 → 70 → 75 → 80
Machine B has followed:
90 → 87 → 84 → 82 → 80
The current value is identical.
The trajectories are different.
Machine A is heating rapidly.
Machine B is cooling.
A model that sees only:
temperature = 80°C
cannot distinguish these situations.
A model that sees recent history can.
This illustrates why sequences matter.
Rate of change contains information
Sometimes we care not only about the current value but also how quickly it is changing.
Suppose electricity demand is:
40 GW
That value alone may not be alarming.
But suppose demand has moved:
35 → 37 → 39 → 40 GW
very quickly.
The direction and speed of change may matter for system operation.
We can therefore derive useful features such as:
- change since previous observation,
- percentage change,
- moving rate of change.
These capture dynamics rather than only levels.
Moving averages
A common way to summarise recent history is a moving average.
Suppose electricity demand during the previous three periods is:
30, 33, 36 GW
The three-period moving average is:
33 GW
As new observations arrive, the window moves forward.
Moving averages can help:
- smooth noise,
- reveal trends,
- represent recent conditions.
But smoothing also removes information.
Sudden changes can become less visible.
Once again, representation involves trade-offs.
Sampling frequency matters
Suppose we measure electricity demand once per day.
We might obtain:
| Day | Average demand |
|---|---|
| Monday | 31 GW |
| Tuesday | 32 GW |
| Wednesday | 31 GW |
Now measure every 30 minutes.
We suddenly see:
- morning ramps,
- evening peaks,
- overnight lows.
The system itself has not changed.
Our temporal resolution has.
This reinforces an earlier principle:
How frequently we measure something determines which temporal patterns we can observe.
Too little sampling can hide important events
Suppose a machine experiences a dangerous vibration lasting:
10 seconds
If sensors record only once every minute, the event may never appear in the dataset.
Or suppose electricity demand spikes for five minutes.
Hourly averages may hide the spike entirely.
The sampling interval must therefore be appropriate for the dynamics of the system.
More frequent sampling is not always better
Very high-frequency measurement can produce enormous quantities of data.
It may also capture:
- noise,
- irrelevant variation,
- redundant information.
Suppose room temperature changes very slowly.
Recording it one million times per second provides little additional useful information.
Sampling frequency should match the speed at which meaningful changes occur.
Irregular time series
Not all observations occur at regular intervals.
A sensor might record every second.
But hospital visits occur whenever patients arrive.
Purchases occur whenever customers buy something.
Machine failures occur whenever something fails.
These create irregularly spaced time series or event data.
For example:
| Time | Event |
|---|---|
| 09:13 | Customer purchase |
| 09:16 | Customer purchase |
| 09:41 | Customer purchase |
| 10:02 | Customer purchase |
The gaps between events may themselves contain information.
Time between events can matter
Suppose a machine normally fails once every five years.
Now failures begin occurring every few weeks.
The timing itself reveals that something has changed.
Likewise:
- time between customer purchases,
- time between hospital admissions,
- time between website visits,
- time between network failures.
The interval between events can be an important variable.
Missing timestamps matter
Suppose a dataset contains:
| Time | Temperature |
|---|---|
| 09:00 | 18°C |
| 10:00 | 19°C |
| 12:00 | 22°C |
What happened at 11:00?
Perhaps:
- the sensor failed,
- the reading was lost,
- no measurement was taken.
We should not automatically assume the value.
Missing time-series observations can create special problems because the gap itself has a temporal structure.
We will examine missing data later in this module.
Time zones matter
Time data can also be deceptively complicated.
Suppose two systems record:
09:00
Are they referring to the same moment?
Perhaps one system uses:
- Dublin time,
and another:
- New York time.
Computer systems often use common standards such as UTC internally and convert to local time for display.
Incorrectly handling time zones can misalign observations and create false relationships.
Daylight-saving time creates complications
In regions using daylight-saving time, clocks can move:
- forward,
- backward.
A day may therefore contain:
- 23 hours,
- 25 hours.
Some local timestamps may occur twice.
Others may not occur at all.
For high-frequency datasets, these details can matter.
Time is not always as simple as incrementing a clock.
Forecast horizon
A forecast horizon describes how far into the future we are trying to predict.
For example:
- one second ahead,
- one hour ahead,
- one day ahead,
- one year ahead.
The appropriate model may depend strongly on the horizon.
A one-second prediction for a vehicle might rely heavily on current velocity.
A one-year prediction may depend much more on broader behavioural and economic factors.
As discussed earlier:
The further ahead we predict, the more opportunities there are for the system to change.
One-step versus multi-step prediction
Suppose we predict electricity demand every hour.
A one-step forecast asks:
What will demand be one hour from now?
A multi-step forecast asks:
What will demand be for each of the next 24 hours?
Conceptually:
NOW → t+1
versus:
NOW → t+1 → t+2 → t+3 → ...
Multi-step forecasting is more difficult because uncertainty accumulates as we move further from the present.
Predictions can feed future predictions
Imagine predicting:
t+1
and then using that prediction as an input for:
t+2
and then using both predictions to estimate:
t+3.
Errors can accumulate.
A small mistake in an early prediction may influence later predictions.
This is one reason long-horizon forecasting can become difficult.
External variables matter
A time series does not necessarily depend only on its own past.
Electricity demand may depend on:
- temperature,
- price,
- day of week,
- holidays.
Traffic may depend on:
- weather,
- events,
- accidents.
Sales may depend on:
- price,
- promotions,
- economic conditions.
So prediction may take the form:
PAST VALUES + EXTERNAL CONDITIONS → FUTURE VALUE
These external variables are sometimes called exogenous variables.
They provide additional context.
Multiple time series can interact
Suppose we want to forecast electricity demand.
We might observe several time series:
- demand,
- temperature,
- wind generation,
- electricity price.
These variables may influence each other.
Likewise, financial markets involve interacting time series for:
- prices,
- interest rates,
- exchange rates,
- volumes.
Real systems often involve many variables evolving together through time.
The challenge is understanding their relationships.
Time series and state
Time-series data connects directly to the concept of state.
Suppose a system has a state at time:
t
We can represent it as:
x(t)
The state evolves:
x(t) → x(t+1) → x(t+2)
Observing this process creates a time series of states.
Prediction asks:
Given previous states and current information, what might the next state be?
Conceptually:
PAST STATES + CURRENT STATE → MODEL → FUTURE STATE
This is the foundation of many dynamical models.
We may observe only part of the state
Often we do not observe the true state directly.
A machine may have an internal level of degradation that cannot be measured directly.
Instead, we observe:
- vibration,
- temperature,
- power consumption.
These variables evolve through time.
Their history can help us infer the hidden state.
So:
TIME-SERIES OBSERVATIONS → ESTIMATE HIDDEN STATE → PREDICT FUTURE
This connects time-series analysis to state estimation and control.
Sequence matters in language too
Time-series thinking extends beyond physical measurements.
Consider language:
The cat sat on the ...
The order of the words matters.
Rearrange them:
sat the on cat The ...
and much of the meaning disappears.
Language is a sequence.
Modern language models learn from ordered sequences of tokens.
The next token depends on the context provided by previous tokens.
At an abstract level:
PAST TOKENS → PREDICT NEXT TOKEN
This is another form of sequential prediction.
Video is a spatial and temporal sequence
A photograph contains spatial information.
A video adds time.
Each frame follows the previous one.
This allows a model to infer:
- movement,
- direction,
- speed,
- actions.
A single image may show a person standing beside a road.
A sequence of images may reveal that they are walking towards the road.
Time adds information about dynamics.
Robotics depends on temporal information
A robot receives observations continuously.
For example:
camera frame(t)
camera frame(t+1)
camera frame(t+2)
Changes between observations help reveal:
- motion,
- velocity,
- direction,
- changes in the environment.
The robot updates its estimate of the world and acts again.
The loop becomes:
OBSERVE → UPDATE STATE → PREDICT → ACT → OBSERVE AGAIN
Time-series data is therefore central to autonomous systems.
Prediction can change the time series
There is another important complication.
Suppose an electricity-price model predicts high prices tomorrow.
Batteries respond by preparing to discharge.
Their behaviour changes future supply.
The price may no longer rise as predicted.
Or a traffic model predicts congestion.
Drivers change route.
The traffic time series changes.
The forecast has influenced the thing being forecast.
So time-series data in social and economic systems may be generated by feedback loops involving predictions themselves.
Historical relationships can stop working
Suppose a model learns:
weekday at 08:00 → high commuter demand
for many years.
Then working patterns change dramatically.
The relationship weakens.
The model may continue predicting the old pattern because the historical time series contains so much evidence for it.
This demonstrates a crucial limitation:
Time-series models often assume that patterns learned from the past remain relevant to the future.
When the system changes, that assumption can fail.
Training and testing must respect time
Time-series data creates a special issue for machine learning.
Suppose we have data from:
2020–2025
and want to test whether a model predicts 2026.
We should not randomly mix future observations into the training data.
A realistic evaluation might be:
2020–2024 → training
2025 → validation
2026 → testing
Why?
Because in the real world:
We train on the past and predict the future.
Our evaluation should respect that direction of time.
Future leakage
Suppose we are predicting demand at 12:00.
If the training features accidentally contain information recorded at 12:30, the model has access to the future.
Its performance may look excellent.
But the prediction is impossible to reproduce in reality.
This is called a form of data leakage.
Time-series modelling therefore requires strict attention to what information was genuinely available at each prediction time.
The arrow of time matters
Time has a direction.
For prediction:
PAST → PRESENT → FUTURE
We can use the past to predict the future.
But we cannot use information from the future to make a genuine historical prediction.
This sounds obvious.
Yet it is surprisingly easy to violate accidentally when constructing datasets.
A model can appear extremely intelligent simply because the data pipeline has allowed it to see information it should not have.
From a table to a process
The most important conceptual shift with time-series data is this:
A normal dataset can sometimes be treated as a collection of observations.
A time series represents a process unfolding through time.
We are observing:
STATE 1 → STATE 2 → STATE 3 → STATE 4
The relationships between those states matter.
This makes time-series data particularly important for understanding dynamic systems.
Questions to ask about time-series data
Whenever you encounter a time series, ask:
- How frequently was it measured?
- Are observations equally spaced?
- Are there missing periods?
- Is there a trend?
- Is there seasonality?
- Are there cycles?
- Are there sudden structural changes?
- How strongly does the current value depend on previous values?
- Which historical periods are relevant?
- Which external variables influence the series?
- What forecast horizon matters?
- Could the system have changed since the historical data was collected?
- Was any future information accidentally included in the model?
These questions help reveal the structure hidden inside the sequence.
The central idea
Time-series data does more than tell us what values occurred.
It tells us how a system evolved.
The order of observations provides information about:
- trends,
- patterns,
- memory,
- dynamics,
- change.
This makes time-series data central to forecasting.
The past is not merely a collection of examples. It is a trajectory that brought the system to where it is now.
A predictive system can use that trajectory, together with present conditions, to reason about where the system might go next.
Our conceptual framework therefore becomes:
PAST TRAJECTORY → PRESENT STATE → POSSIBLE FUTURE TRAJECTORIES
But time is only one dimension along which data is structured.
Events also occur somewhere.
In the next lesson, we will examine spatial data and how location, distance, neighbourhood and connectivity shape what models can learn.