Advanced Octave A54 — Model comparison and validation

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 09

A model can adapt very well to the data used to estimate it and predict worse new data. We separate training and test in a small time example.

Objectives and prerequisites

Let’s repeat A52’s synthetic series. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import convalida.m, register it and run it in the Runner. The Dataset octave_advanced_holdout_prediction is created-only: to repeat, use a new session or change the ID.

Divide before esteem

The seven points between 0 and 3 are the training; the four between 3.5 and 5 are the test. polyfit estimates a first degree and third degree polynomial using only training. Then polyval calculates the forecasts on all times and the script calculates separately the RMS of the residuals of the two sets. NUMERIC_API_v1 also summarizes the average test residues of the third degree.

In the test the linear model has RMS about 0.136982 on the training and 0.740686 on the test. The cubico has RMS about 0.008584 on the training and 0.309774 on the test. In this example the cubico gets a test error lower than the linear one, but its test error is much larger than the training one. Cubic forecast is published as Dataset: it is not a new observation.

Interpretation

The test is later in time, so evaluate here an extrapolation beyond the training interval. It is a choice to illustrate a future forecast, but four synthetic points are not enough to establish general performance. The decay that generates data is not a polynomial: a good local adaptation does not guarantee plausible behavior far from the data.

In a real case, choose the division before evaluating the results, prevents the test information from entering the estimate and considers more periods or independent groups. Compare also models motivated by the phenomenon, residues and uncertainties; do not choose on the only goodness of the training.

Exercise

  1. What time are they reserved for the test?
  2. Which model has less RMS on the test in this test?
  3. Does the excellent training error of the cubico guarantee reliable extrapolations?

Worked solution

  1. The four times from 3.5 to 5 s.
  2. The cubicle, about 0.309774 versus 0.740686 of the linear.
  3. No: the error on the test is much larger and the behavior outside the range should be evaluated carefully.

Download the Module 09 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *