Question: Need help with Artificial Intelligence question. Have to write code for B and W. So before the statement to compute w, you need to compute
Need help with Artificial Intelligence question. Have to write code for B and W.


So before the statement to compute w, you need to compute two terms. The first term is the dot product of the transpose of x_new with x_new, and then the pseudo-inverse of that (note that this is the pseudo-inverse operator. The second term is the dot product of the transpose of X_new with y. * = Let's compute the first term. The numpy package which has been imported as 'np' provides the 'dot' function to compute the dot product. The transpose of a numpy matrix such as x new can be found by putting a'.t' at the end of the matrix (this is since the transpose of the matrix is available as the Tinstance variable of the matrix object in numpy). So the first term, not including the pseudo-inverse of it is (if you are calling it P) - P = np. dot(x_new.T,x_new) The pseudo-inverse is a function in numpy named pinv available within the sub-package linals, so N below is the pseudo-inverse of the previously computed P- N = np.linalg.pinv (P) Our next task is to compute the second term which is the dot product of the transpose of x new with y. Now you know how to do a transpose, and you also know how to do a dot product, so this step is left for you to complete (let's say you compute it as the variable B) - B = # THIS EXPRESSION IS LEFT FOR YOU TO WRITE The final step now is to write the expression for w and we are done! This expression is just the dot product of the two sub-expressions we have computed and previously named as N and B. This is also left for you to do. w = # THIS EXPRESSION IS LEFT FOR YOU TO WRITE # weights learned by solving linear system
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
