Here we'll consider a simple example of linear regression with polynomial features, because it's the easiest to visualize. We'll use the following generative model.
for being our feature map, being a parameter vector, and denoting the Gaussian distribution with mean and variance .
We'll start by setting , , and make the training set size and the validation set size .
This diagram visualizes what is going on. On the left, we plot the dataset (with the training set in blue and the validation set in red) along with the predictor in green for a particular ridge regression parameter . On the right, we plot the training loss, validation loss, and expected loss over the source distribution, on a log-log plot against the ridge regression parameter on the -axis. Every time you refresh the page, you get a new dataset. You can also click-and-drag the points to change the dataset.
Train loss: 0.00591Validation loss: 0.00591Expected population loss: 0.0379