Sample Exam For ML YSZ: Question 1 (Linear Regression)
Sample Exam For ML YSZ: Question 1 (Linear Regression)
Sample Exam For ML YSZ: Question 1 (Linear Regression)
1
• [t,X] = loadData(): loads data from ’housing.data’ data file. t is the target
output and X is the input features.
• X n = normalizeData( X, ref ): Normalizes the data in X using the mean
and variance of the data in ref. If ref=X, then X n is a linear transformation of
X with zero mean and unit variance.
For the following, use these normalized features X n and targets for learning the model.
Have a look at the source code for all provided files. You may be able to use the
structures as hint.
Page 2
(d): [+CODE] Create a MATLAB script polynomial regression reg.m for the
following:
Implement L2 -regularized regression using the first 100 points, and only the 2nd
feature. Fit a degree 8 polynomial using each value in {0, 0.01, 0.1, 1, 10, 100, 1000}
for λ. Use 10-fold cross-validation to decide on the best value of λ. Produce a plot
of average validation set error versus the regularizing constant λ. Use a semilogx
plot, putting the regularizing constant λ on a log scale2 .
Put this plot in your report, and note which regularizing constant λ
you would choose for the cross-validation.
Page 3
Question 2 (Fisher Distance): Imaging X is a random variable generated
from the two classes C1 and C2 , and the data from two classes are Gaussian. Suppose
a is the random variable X|C1 and b is X|C2 :
a ∼ X|C1 ∼ N µ1 , σ12
b ∼ X|C2 ∼ N µ2 , σ22 ,
while a and b are statistically independent, and (µ1 > µ2 ).
We define random variable c = a − b. Each sample of c is generated by a random
sample from C2 , subtracted from a random sample from C1 .
Page 4