Machine Learning Programming Exercise 5
Due 14th December, 2015. Please upload to LMS before midnight.
1 Bias and Variance [100 points]
The ex5_x.dat and ex5_y.dat contain the inputs ( () ) and outputs ( () ) for linear regression problem.
Use part of your data to train your model and then test your results. For this purpose, use 60% of the
data as training set, 20% of the data as cross validation set and use the rest of the data as test set.
i.
[10 points] Perform a linear regression without regularization (using 80% of the data as
training set). Calculate the error using the test set.
ii.
[45 points] Add polynomial features up to x^6 for your regression model. For different
degrees of the polynomial, calculate optimal theta on the training set. Plot degree vs. error
that you obtain using cross validation set and the corresponding thetas. Choose the best
degree using this plot and then calculate test set error.
iii.
[45 points] This time fix your degree of the polynomial to the value you obtained in the
second part of the assignment. Find best regularization parameter in the same way you do
in (ii). Here plot lambda vs. error. Report test error for the best lambda.