Evaluating forecasts on held-out data: comparing sources fairly

Freeze forecasts before events, admit later observations and compare sources on the same sample.

Sky, observations and an archive suggest comparing a forecast with data received later.
Sky, observations and an archive suggest comparing a forecast with data received later.

Two weather services may show different temperatures for tomorrow. Choosing a source for a product requires more than opening them after the event and comparing their current responses with an observation. We need to know exactly which forecast was available when the decision was made, which place and time it concerned, and which measurement was used for comparison.

We will start with a protocol for that comparison. The real archived-forecast experiment has not yet been run: two suitable forecast archives and verified observation provenance are still needed. There is therefore no basis for a provider ranking yet. There is a small executable example with invented data: it shows how a delay, a corrected record or a missing observation changes the sample before any error is calculated.

Define the decision the evaluation will support

“Which model is better?” is too broad. For a city page, a more useful question might be: “Which source supplies a suitable temperature forecast for the selected locations one day ahead when the page updates at a specified time?” Both the accuracy of available values and availability at the required moment matter.

There are two different comparison designs. One compares the same model initialization cycles at the same lead times. The other fixes the time of the user's decision and takes the latest version actually available from each service before that time. The second design may compare runs of different ages. That is reasonable for evaluating a service if the difference remains visible in the results.

Our example chooses the first design with an additional availability cutoff. A forecast must belong to the exact specified cycle and arrive before the cutoff. A newer cycle cannot silently fill a missing cell. This is a rule of this exercise, not a universal evaluation procedure for every weather product. ECMWF describes different scores for different weather variables and lead times; one overall score does not replace a precise question.

Freeze the plan before inspecting errors

The plan should specify the sample, selection rules and calculation method in advance. A compact table is sufficient for an initial exercise.

Part of the plan Decision in the teaching example
Quantity Instantaneous temperature in °C
Space Two fictional points with explicit identities
Lead time Separate groups at 24 and 48 hours from initialization
Forecast availability Version received no later than 600 seconds after initialization
Observation Same point and exact valid time; compatible unit
Observation freeze Versions available by valid time plus 172800 seconds
Quality control The latest revision eligible by time must have accepted QC
Comparative sample Intersection of eligible cases from both sources
Measures Case count, coverage, bias, MAE and RMSE separately for each lead time

The numbers 600 and 172800 were chosen for the synthetic exercise. In a real flow, they must reflect product requirements and observation reporting rules. They should not be tuned after seeing which source benefits from a longer allowance.

We also freeze the locations and period. Removing an inconvenient station or a rainy week after the first results changes the research question. Such a new analysis is possible, but it needs its own plan version and an explanation of the reasons.

The archive must preserve what was known then

For every forecast, retain the source, cycle, valid time, first confirmed availability, revision, quantity, unit and original record. A correction becomes a new version. It must not overwrite old bytes as though the correct answer had been known from the beginning.

Suppose a run was initialized at 0 and the product makes its decision at second 600. The first version, with value 11, is available at second 300. A corrected version, with value 10, arrives at second 700. The decision still uses 11, even if the provider returns only 10 the following day.

Downloading a historical file today does not prove that it was available yesterday. A field called issued_at also needs defined semantics: it might mean model initialization, product publication or response creation. Read an archive API together with its contract; for example, Open-Meteo separately documents its Historical Forecast API. That documentation says the Historical Forecast API stitches the first hours of successive runs into a continuous series and directs users to the Single Runs API for the full horizons of individual cycles. A stitched series is not a direct substitute for the fixed 24/48-hour cycles in our design.

The teaching code takes availability as an input fact. It cannot certify when an external record first appeared. A real experiment needs collection logs or suitable archive evidence, along with permission to retain and reuse the data.

Observations have their own versions and limits

The time of the measured phenomenon, arrival of the report and correction of that report can differ. Observations arriving after the forecast horizon ends are expected: they verify an event that had not happened when the forecast was issued. The problem arises when future information silently changes the selection or content of the forecast itself.

For reproducibility, our plan has a separate observation freeze. Correction revisions arriving before it are eligible. A later correction may justify a new report, while the old report retains its own observation versions. We should not require every measurement to have been known before the forecast; we need two separate time barriers.

The latest revision available by the freeze is selected first, and its QC is checked afterwards. If that latest report is rejected, the code does not return to an older “good” value. Such a fallback would silently bypass the quality decision. A missing or unsuitable measurement excludes the case from error scoring with an explicit reason.

Physical compatibility also matters. Instantaneous temperature cannot be matched with a daily maximum. A point on a slope cannot be equated with a distant station merely because both use the same city name. Real stations require checks of coordinates, elevation, measurement characteristics and the spatial matching rule. The forecast verification working group discusses observation and representativeness errors; they belong in the interpretation of a result.

Another trap is a weather endpoint that returns an observation when available and a model value as a fallback. That may be a useful interface policy. A reference dataset for forecast evaluation needs explicit provenance for each row: a model value does not become an independent observation because an API calls the field “current temperature.”

A held-out period protects against fitting the rules

Parsers, normalization and thresholds need a separate earlier development period. Use it to find bugs, clarify units and decide how to handle missing values. Then freeze the rules and evaluate them on a later held-out period.

If we change the station selection rule or temperature correction after inspecting that period, it has already helped tune the system. It can remain in the development history, but the next independent conclusion needs another held-out period. Randomly distributing neighbouring hours between development and evaluation does not establish that time boundary.

This also applies to a simple baseline. A persistence forecast, for example, can use the latest observation available at decision time. Taking a later corrected measurement that had not yet arrived would give the baseline extra information. Our code does not implement a baseline; adding one requires a separately frozen rule.

Missing records change the comparison

Suppose one source supplies forecasts for all four planned cases and the other for only three. Calculating each source's MAE over its own rows may compare different weather. A smaller error can partly reflect the absence of the hardest case.

We therefore calculate comparative metrics on the common sample: both forecasts are eligible and the same observation passes the rules. Alongside the scores, show the planned count, availability of each source, common case count and exclusion reasons. The intersection can itself be biased, for example if outages occur more often in bad weather. The coverage table helps expose that problem; it does not eliminate it.

A source's own subset remains useful for diagnostics. The code reports those results separately under own_subset_diagnostics_not_comparable. They do not replace the paired table. Missing forecasts and observations do not become zero degrees, and missing cases do not disappear from the planned coverage denominator.

Three measures answer different questions

Define the error as e = forecast − observation. For the same set of rows:

bias = sum(e) / n
MAE  = sum(abs(e)) / n
RMSE = sqrt(sum(e * e) / n)

Bias shows the average direction of deviation. MAE is the average absolute error. Squaring makes large errors influence RMSE more strongly. These definitions appear, for example, in NOAA's verification glossary. For temperature, all three numbers have the unit °C; show the row count beside them.

For two errors of −2 and +2, bias is 0, while MAE and RMSE are both 2. Zero average bias therefore does not mean an accurate forecast. When there are no eligible pairs, our code returns n = 0 and null metrics. Reporting zero error in that situation would be misleading.

The temperature exercise should not be mechanically extended to every phenomenon. Precipitation, for example, depends on its accumulation interval and event characteristics; ECMWF describes a separate precipitation measure, SEEPS. A probabilistic answer likewise needs evaluation of probabilities, not just one selected value.

A small run makes selection visible

The package contains independent evaluate.py, synthetic-cases.json and test_evaluate.py files. All data are invented; Aster and Boreal are fictional names. Time is expressed in relative seconds. Run from the example directory:

python test_evaluate.py
python evaluate.py

The Python 3.12.3 run executed 25 test methods. They check time boundaries, frozen revisions, refusal to reuse an old value after negative QC, conflicting immutable versions, exact location identity, coverage and arithmetic. These are tests of a program on synthetic data. They do not add real weather observations to the experiment.

Four cases are planned at a 24-hour lead time. Aster is available for four, Boreal for three. One case is excluded because Boreal's forecast arrived late; another is excluded because the latest observation revision was rejected. Two paired rows remain:

Synthetic source Pairs Bias, °C MAE, °C RMSE, °C
Aster 2 1.5 1.5 1.5811
Boreal 2 −0.5 0.5 0.7071

The separate 48-hour group has two planned cases and only one paired case. We do not add it to the previous group to obtain a more attractive overall number. All these values describe a deliberately constructed arithmetic example. They let us check the report and do not justify selecting a real provider.

A conclusion should retain its sample limits

A real report should break results down by lead time, location or predefined groups of conditions. A large city with frequent observations should not silently dominate the total if the decision concerns equal quality across locations. Weights and aggregation rules belong in the plan. Dependent neighbouring hours and stations should not be treated as independent repetitions without explanation.

For uncertainty intervals, one option is paired block resampling by date or weather episode, preserving the same cases for both sources. Block size needs justification; this example does not perform that calculation. With a small sample, the honest result may be that a difference has not yet been established reliably.

Move to a real comparison when a permitted archive of original versions, verified observation provenance, a frozen plan and a sufficient held-out period are available. Retain the selected pairs, exclusion reasons and rule versions alongside the final score. That record makes the evaluation reproducible, explains changes in the results and supports choosing a source for a specific task with understood limits.

  1. Weather The provider is late: when can a forecast remain on display?
  2. Weather Degrees, wind and precipitation: normalize units without losing meaning
  3. Weather Multiple weather providers: a shared contract without losing important differences
  4. Weather Forecasts and observations: what weather data does the user see?

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article