Skip to content
Tactiverge

School/□ Systems Engineer/Week 9

Validating a model and stating its limits

Your cooling model fits the first 30 minutes beautifully. Does it predict the next 30? The only honest way to find out is to keep some data back.

About 45 min · 3 goals · Checked by automated tests

1.Why should I care?

A model that is only checked on the data it was fitted to has not been tested at all. Validation, with honest limits, is what separates a model someone can rely on from a curve that happens to pass through some dots. It is also the core of your term project.

  • ◇ Distinguish verification (solving the equations right) from validation (solving the right equations).
  • ◇ Fit on part of the data, test on the held-out part and quantify the error with RMS and percentage error.
  • ◇ List a model's assumptions and predict the direction of each one's effect.

2.Predict

A model fitted to the first half of a data set has RMS error 0.4 °C on that half. On the held-out second half its error will most likely be…

Guess first. Being wrong here is how the surprise works.

3.Understand

Verification and validation

Verification: does the code solve the equation correctly? Check against an exact solution and by halving the step (week 8). Validation: does the equation describe the real system? Check against data the model was not tuned on. A perfectly verified model of the wrong physics is still wrong.

Hold-out testing

Split the data before fitting: fit on one part, then predict the other. Report the error on the held-out part, with units: RMS = √(mean of squared residuals), or percentage error |model − data|/data. For time series, hold out the later part: that is what a prediction actually has to do.

Assumptions and their effects

Cooling model: well-mixed liquid (one temperature), constant room temperature, constant k (in fact convection and radiation make k vary with temperature), no evaporation (which speeds early cooling). Drag model: linear drag (often quadratic in air), still air. For each, say which way it pushes the prediction and when it matters.

Explain it another way

Practising only the exam questions you have already seen tells you nothing about the real exam. Holding out data is keeping some questions back to test yourself honestly.

Worked example 1

Held-out residuals are 1, −1, 2 and −2 °C. What is the RMS error?

Squares: 1, 1, 4, 4; mean 2.5; RMS = √2.5 = 1.58 °C.

Common mix-ups

  • A low error on the fitting data validates a model.
    ✓ Only error on data not used for fitting tests whether the model generalises.
  • Listing limitations weakens a report.
    ✓ Stating limits honestly is what makes the remaining claims trustworthy.

4.Discover

Choose the mug of tea and switch on 'Hold out the second half'. Press Best fit (it now uses the first half only). Compare the RMS errors on the fitting and held-out data. Then deliberately set k 20% too high: which error grows more, and why?

Loading the interactive…

Can't use the interactive? Read a description instead

With the hold-out option, the decay-fit lab fits k on the first eight cooling readings (filled dots) and tests it on the last eight (hollow dots). The readout gives the RMS error on both parts; with the best-fit k both are well under 1 °C. Setting k 20% too high makes the held-out error grow much more than the fitting error, because errors in k accumulate over time.

5.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Held-out residuals are 1, −1, 2 and −2 °C. What is the RMS error, in °C?

°C

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

The model predicts 50 °C where the held-out reading is 52 °C. What is the percentage error, relative to the reading?

%

Practice 3

You halve Euler's step and the simulated temperature barely changes. What have you shown?

Practice 4

On held-out data, a cooling model's residuals (data − model) are all positive and grow with time. Which explanation fits best?

Practice 5 · a fresh version every time

A mug of tea at 75 °C cools in a 25 °C room as T(t) = Tₐ + (T₀ − Tₐ)·e^(−kt) with k = 0.02 per minute. What is its temperature after 20 minutes, in °C?

°C

7.Apply it

Take your fitted k from the previous lesson. Predict the temperature 10 minutes beyond your last reading, then (if you collected data safely) measure it. Report the error and the one assumption most likely to explain it.

8.Reflect

Concepts: Overfitting and held-out tests · Simulation and time stepping · First-order differential equations