Lab 24 · Lecture 24 · Polynomial, Exponential and Trigonometric Fitting
Curve Fitting Lab
Fit polynomials, exponentials, power laws and periodic models to your own data, and see overfitting happen.
Choose the model; for a polynomial set the degree, for the trigonometric model the period. The table lists fitted values and residuals.
Ten noisy samples of sin 2πx. Move the degree; the right plot shows training and test error for every degree. Turn on ridge regularisation (λ) to tame high degrees.
Polynomial fit
Try this
Exponential fit
Try this
Q1 Write the normal equations for fitting .
; ; .
Q2 How do you fit by least squares?
Take logarithms: . Fit a straight line to the points ; the slope is and .
Q3 How do you fit ?
: fit a straight line to .
Q4 Why is fitting not the same as fitting ?
It minimises the squared errors of , i.e. roughly relative errors, so small values of get more weight; the result differs slightly from minimising .
Q5 What is overfitting and how is it detected?
A model with too many parameters fits the noise of the training data: training error is tiny but error on new data is large. It is detected by measuring the error on data not used for fitting (validation or test data).