Skip to content

Commit 2d52483

Browse files
author
Merouane Atig
committed
Calculate error for training set
1 parent 55a2e0f commit 2d52483

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

mlclass-ex5/learningCurve.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@
5858
for i = 1:m
5959
Xset = X(1:i, :);
6060
yset = y(1:i);
61-
theta = trainLinearReg(X, y, 0);
61+
theta = trainLinearReg(Xset, yset, lambda);
6262
error_train(i) = linearRegCostFunction(Xset, yset, theta, 0);
63+
theta = trainLinearReg(Xval(1:i, :), yval(1:i), lambda);
64+
error_val(i) = linearRegCostFunction(Xval, yval, theta, 0);
6365
end
6466

6567

0 commit comments

Comments
 (0)