Consider a synthetic data based on the sinusoidal function which is generated from the function $\sin(2\pi x)$ with random noise included in the target values. Suppose that we are given a training set $X\equiv(x_1,\cdots,x_N)^{\text T}$, together with corresponding observations of the values $T\equiv(t_1,\cdots,t_N)^{\text T}$.

The goal is to achieve good generalization by making accurate predictions for new data. In particular, we shall fit the data using a polynomial function of the form

$$ y(x,\bold w)=\sum_{j=0}^Mw_jx^j $$

with $\bold w=(w_0,\cdots,w_M)$.

We fit the polynomial to the training data by minimizing an error function that measures the misfit between the function $y(x,\bold w)$, for any given value of $\bold w$, and the training set data points, then the resulting polynomial is given by the function $y(x,\bold w^*)$. Here we use the following function as error function

$$ E(\bold w)=\frac{1}{2}\sum_{n=1}^N\{y(x_n,\bold w)-t_n\}^2 $$

We can obtain some quantitative insight into the dependence of the generalization performance on $M$ by considering a separate test set comprising 100 data points generated using exactly the same procedure used to generate the training set pings but with new choices for the random noise values included in the target values. For each choice of $M$, we can then evaluate the residual value of $E(\bold w^*)$ for the training data and test data set. In this case, we use the root-mean-square(RMS) defined by

$$ E_{\text {RMS}}=\sqrt{2E(\bold w^*)/N} $$

as the residual value of $E(\bold w^*)$. The test set error is a measure of how well we are doing in predicting the values of $t$ for new data observations of $x$.

The more flexible polynomials with larger values of $M$ are becoming increasing tuned to the random noise on the target values. This behavior is known as over-fitting.

A simple way to determine a suitable value for the model complexity is to take the available data and partitioning it into a training set, used to determine the coefficients $\bold w$, and a separate validation set, used to optimize the model complexity (either $M$ or $\lambda)$. In many cases, however, this will prove to be too wasteful of valuable training data.