Gate: close the gap without underfitting (AI off)
Why it matters Closing a train/validation gap is easy if you are allowed to make the model useless. Doing it while keeping the model good is the real skill. Already know this module? You can take this gate first, before the other lessons: passing it marks this module done and opens the next one.
AI tutor off. A degree-14 polynomial on 25 points overfits badly. You must keep degree 14 and use weight decay (ridge, from the bias and variance lesson), choosing its strength with the validation set.
Because you choose alpha by looking at the validation set, the validation error is now a little flattering. So the gate scores you on a separate test set of 2,000 fresh points that your code never sees. That is the honest way to report a model you tuned.
Words and symbols in this lesson
- overfitting, underfitting
- fitting the noise in the training data; or too simple to fit the pattern
- validation set
- held-back data used to choose settings
- bias, variance
- being wrong in the same way every time; or changing a lot with the training data
- ridge (alpha)
- least squares with weight decay of strength alpha
Write fit(x, y) returning coefficients (lowest power first) for a degree-14 polynomial. It must be a ridge solution, solve(A.T A + alpha I, A.T y) for some alpha above 0 (the test checks this, so a smaller polynomial padded with zeros does not count). Pass if the error on the hidden test set is below 0.045 and the gap (test minus training) is below 0.05. For scale: plain least squares has a test error of about 0.73, the best possible alpha a test error of about 0.034, and an alpha chosen honestly on the validation set, on any sensible grid such as powers of 10, a test error of about 0.034 to 0.039. A flat, over-shrunk fit fails the 0.045 limit.
AI off: no tutor, hints or worked solution on this one. Your own thinking only.
Spotted a problem in this lesson? Report it · Ask about this lesson
Your progress is counted anonymously. Change this
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.