Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
1 & 2
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Nov 19, 2011
1 parent 591e29e commit 896b01c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mlclass-ex5/mlclass-ex5/linearRegCostFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@



h = X*theta;

% regularize theta by removing first value
theta_reg = [0;theta(2:end, :);];
J = (1/(2*m))*sum((h-y).^2)+(lambda/(2*m))*theta_reg'*theta_reg;

grad = (1/m)*(X'*(h-y)+lambda*theta_reg);





Expand Down

0 comments on commit 896b01c

Please sign in to comment.