Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Machine hw1
1. Math 156
Homework1(Cui Yi) ID number:605068398
Math 156
Homework1(Cui Yi) ID number:605068398
Q1.
Solution
Q2.
Solution
Q2.1
Q2.2
Q4.
Solution
Q5.
Solution
Q6.
Solution
Q7.
Solution
Q8.
Solution
2. Q1.
Compute the gradient J (w ) and show that the equation J (w ) = 0
may be written in the form Aw = b where A is a matrix and b is a vector.
Solution
Cost function: ,
Obviously, we can easily
Then, using the chain theory,
Setting the , then
1°when is invertible , , Remark: Ker(A)={ }
2°
Rm: the form ,when is vertible, then
3. Figure 1
Q2.
Does the equation J (w ) = 0 always have a solution? If there is a solution is it unique? Explain how
these two questions are related to the number of data points N and the degree M of the polynomial
model.
Solution
Q2.1
The equation J (w ) = 0 does not always have a solution.
For example, it will meet the problems like over-fitting.(Figure 1)
When the M becomes bigger, it will cause the over-fitting problem. At this time, the equation J (w )
= 0 does not always have a solution.
Also, it will finally make the inaccuracy in the test set while it may have better performance in the
training set.
Intuitively, what is happening is that the more flexible polynomials with larger values ofM are
becoming increasingly tuned to the random noise on the target values.
4. Figure 2
Figure 3
Q2.2
From the point of RANK, we know rank(Z) , and
If ,the solution is not unique.
If the solution is unique.
In the book, we can easily see the difference of different N(N is the point)
We see that increasing the size of the data set reduces the over-fitting problem.
But what we should bear in mind is that the larger the data set, the more complex (in other words
more flexible) the model that we can afford to fit to the data.
5. Figure 4
Q4.
Solution
Those twelve points are illustrated on the picture.
x=[-pi:0.001:pi];
y=cos(2.*x);
plot(x,y);
hold on
xi=linspace(-pi,pi,12);
yi=cos(2.*xi);
plot(xi,yi,'r*');
title('Task 4', 'FontSize', 16);
ylabel('cos(X)', 'FontSize', 15);
xlabel('X', 'FontSize', 15);
6. Q5.
Solution
The same as Task 1, and ,
We can easily get the result with two situations. And the final form is
1°
2° , Remark: Ker(A)={ }
Here, z , t
10. Figure 8
Q8.
Solution
From the figure,we can easily find that M=6 is th best fitting.
Here are two situations where I choose the x data
X = rand(12, 1)*2* pi- pi ;