Learning From Data - Homework 6 - A solution in LIONoso
Courtesy of Giovanni Pellegrini
We provide our solution to exercises 2,3,4 and 5, all about overfitting.
In exercise 2 we study the in- and out-of-sample error of linear regression, in the other exercises
we see how weight decay affects the error, choosing different values of λ.
Before proceeding, be sure to have Python and numpy installed on your computer.
Connecting the "Overfitting" Python script to LIONoso
You can download the "overfitting algorithm" script,
containing our solution.
You can also download training and testing files here:
Please see the notes for Windows users
if you use this operating system.
You can load the script by dragging a Parametric
table into the workbench, and by specifying the filename of your script.
In the above figure we just loaded the script (Exercise2-Overfitting.py).
In the left panel you can specify the training and testing files, and the value of λ.
You have to specify the complete file path otherwise the script will not work.
By clicking the "Compute" button, the script is launched and a table containing the results of each experiment
To solve exercise 5, run the script for all requested values (from -2 to 2) and
identify the one corresponding to the lowest error.
Solutions for each exercise are provided below:
in-sample error : 0.028
out-of-sample error : 0.084
Exercise 3 (k = -3):
in-sample error with weight decay: 0.028
out-of-sample error with weight decay: 0.08
Exercise 4 (k = 3):
in-sample error with weight decay: 0.37
out-of-sample error with weight decay: 0.43