Midem ML Makeup Sol Upated
Midem ML Makeup Sol Upated
Input X Output Y
1 exp(2)
2 exp(4)
3 exp(6.3)
4 exp(9.2)
valued of the form yi = f ( xi ) + ei , where f(xi) is the true function and ei is a random
variable representing laplacian noise with PDF given by
− yi −
1
f ( yi ) = *e
2
n
h ( xi ) = i xi
Implementing a linear regression model of the form i =0 , and = h ( xi ) ,
find the maximum likelihood estimator of . Comment on the loss function. [4+1 Marks]
0 yˆ = y
1
( yˆ , y ) =
yˆ = Fail and yˆ y
Yˆ argmax l ( y, yˆ ) P (Y = yk ) Πi P(X i |Y = yk )
yk
Use this modified hypothesis function to classify each of the examples in the given
table. [5 Marks]
Solution:
p(y|x)
Fail second class first class
25 0.35 0.12 0.02
50 0.1 0.09 0.02
75 0.05 0.06 0.06
100 0 0.03 0.14
Q.4 If we modify the loss function of the linear regression model as follows:
(h ( x ) − y )
n 2
1
J ( ) =
2n
w
i =1
(i )
(i ) (i )
Where w(i) is the weight assigned to each training example. Derive the equation to
find the value of with this modified loss function. Suppose, we estimate the value
of w(i) inversely proportional to the variance of the residuals, comment in no more
than 20 words when you prefer to use this kind of modified loss function.
[3+2=5 Marks]
Solution:
Comment: Robust against outliers. Outliers will have higher variance of the residuals
resulting into lower weight.
Q.5 Fit a logistic regression. Find the updated weights after the 3 iterations of modified
Gradient Descent algorithm where gradient update happens after every training
example using a learning rate of 0.5 and initial weights (W0, W1, W2) = (1, 1, 1) for
the
following data with the logistic regression output given by
1
1+ e
( −W +W X
0 1 1 −W2 X 2
2
)
Assume the results obtained after 3 iterations is the final weights. Using this construct
the confusion matrix for given below training data. [4+2=6 Marks]
Solution:
Wi-LR*[Y-Pred – Y ]* Xi
Y-Pred =
X1 X2 y h(X) W0 w1 w2
2 0 0 0.05 0.975 0.95 1
0 2 0 0.95 0.5 0.95 0.05
0 -2 0 0.27 0.365 0.95 0.32
-2 0 0 0.05
w0 w1 w2
0.365 0.95 0.32 True Class
Y-
Pred
Confusion Matrix Y=0 Y=1
=
X1 X2 y h(X) Y
2 0 0 0.03 0 Predicted Y=0 3 0
0 2 0 0.73 1 Class Y=1 1 2
0 -2 0 0.43 0
-2 0 0 0.03 0
0 1 1 0.66 1
0 -1 1 0.51 1
Q.6 Consider the following set of training examples:
Instance Classification A1 A2
1 + T T
2 + T T
3 - T F
4 + F F
5 - F T
6 - F T