[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

  

posted @ 2017-03-08 22:18  KennyRom  阅读(223)  评论(0编辑  收藏  举报