Skip to content

Commit 23e31fc

Browse files
author
Merouane Atig
committed
Calculate cost function
1 parent 518f081 commit 23e31fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mlclass-ex5/linearRegCostFunction.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
% You should set J to the cost and grad to the gradient.
2020
%
2121

22-
23-
24-
22+
htheta = X * theta;
23+
n = size(theta);
24+
J = 1 / (2 * m) * sum((htheta - y) .^ 2) + lambda / (2 * m) * sum(theta(2:n) .^ 2);
2525

2626

2727

0 commit comments

Comments
 (0)