Regularized linear regression gradient
This commit is contained in:
parent
6530916642
commit
2d6da3e3d4
1 changed files with 2 additions and 0 deletions
|
@ -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(:);
|
||||
|
|
Reference in a new issue