You are on page 1of 1

Assignment-5

19AIE205-Python for Machine Learning

Date:06.09.2020.
Deadline for Submission: 14.09.2020 @ 9:00A.M.
Max.Marks: 20 marks.

1. a. Write the corresponding Python Code for the below given matlab code. 15 marks.

m=5; c =10 ; % slope and intercepts


x= (-5:5)'; % x is a column vector
y=m*x+c; % y is a column vector
n=length(x); % number of data points
% let us generate n disturbing values from normal distribution with
% sigma=5 . That is, standard deviation =5
noise= 5*randn(n,1); % nx1 column vector
yd=y+noise;
A=[x ones(n,1)];
Alpha= inv(A'*A)*A'*yd;
ycap=A*Alpha;
plot(x,yd,'*') ; % plot scattered data points
hold on
plot(x, ycap); % plot the regression line
xlabel('independent variable x')
ylabel('dependent variable y')

b. Write the python code to compute the error vector and check whether the error vector is
orthogonal to the column space of A. 5 marks.

You might also like