1
0
Fork 0

Regularized linear regression gradient

master
neingeist 10 years ago
parent 6530916642
commit 2d6da3e3d4

@ -22,6 +22,8 @@ grad = zeros(size(theta));
J = 1/(2*m) * sum(((X*theta)-y).^2) ...
+ lambda/(2*m) * sum(theta(2:end).^2);
grad = 1/m * X' * ((X*theta)-y) + (lambda/m) * [0; theta(2:end)];
% =========================================================================
grad = grad(:);