You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

normalEqn.m 675 B

8 years ago
1234567891011121314151617181920212223
  1. function [theta] = normalEqn(X, y)
  2. %NORMALEQN Computes the closed-form solution to linear regression
  3. % NORMALEQN(X,y) computes the closed-form solution to linear
  4. % regression using the normal equations.
  5. theta = zeros(size(X, 2), 1);
  6. % ====================== YOUR CODE HERE ======================
  7. % Instructions: Complete the code to compute the closed form solution
  8. % to linear regression and put the result in theta.
  9. %
  10. % ---------------------- Sample Solution ----------------------
  11. theta = pinv(X' * X) * X' * y;
  12. % -------------------------------------------------------------
  13. % ============================================================
  14. end

机器学习

Contributors (1)