1
0
Fork 0

Compute Cost (for one variable)

This commit is contained in:
neingeist 2014-10-01 22:05:13 +02:00
parent bc0eb3519f
commit 14c85aa85c

View file

@ -13,9 +13,11 @@ J = 0;
% Instructions: Compute the cost of a particular choice of theta
% You should set J to the cost.
predictions = X * theta;
errors = predictions - y;
squared_errors = errors .^ 2;
J = 1/(2*m) * sum(squared_errors);
% =========================================================================