首页 > 代码库 > [ML] CostFunction [Octave code]

[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

  

[ML] CostFunction [Octave code]