[ML] CostFunction [Octave code]

function J = computeCostMulti(X, y, theta)

m = length(y); % number of training examples

J = 0;

for i = 1:m
	J = J + (X(i,:) * theta - y(i,1)) ^ 2
end;

J = J / (2 * m);

end

  

原文地址:https://www.cnblogs.com/KennyRom/p/6523381.html