POSTECH · CSED105 · LECTURE 6

Choosing a Hyperparameter: Polynomial Degree

A more complex curve can fit training data closely, yet predict poorly on new data. Explore how the polynomial degree affects this trade-off. Training, validation, and test points are sampled independently around the same hidden polynomial, with independent noise.

Explore: Move the degree slider and compare the fitted curve and errors. New data also change the hidden degree that generated them.

Choose: Use validation error to select a degree.

Reveal: Keep moving k and compare all three error curves. In practice, never use test error to choose k.

3

Higher k allows a more flexible curve.

Model fit

The curve is fit using training points only.

Polynomial regression fit Training and validation observations with the selected polynomial curve. Test observations appear after the test set is revealed.
Training data Validation data

Error as degree changes

Training and validation RMSE by polynomial degree A line chart compares training and validation root mean squared error for degrees one through ten. The selected degree is highlighted.
Training RMSEValidation RMSE
Training RMSE
—
Validation RMSE
—
Compare the two errors as k changes. Training error usually keeps falling; validation error may rise again.
Think about it

Which degree would you choose based on validation RMSE? Does the test error tell the same story?