Machine-Learning-Coursera-code icon indicating copy to clipboard operation
Machine-Learning-Coursera-code copied to clipboard

use the vectorization to accelerate the calculation

Open comeonsunny opened this issue 3 years ago • 0 comments
trafficstars

% ====================== YOUR CODE HERE ====================== % Instructions: Compute the cost of a particular choice of theta % You should set J to the cost. sum = 0; temp_cost = X * theta - y; for i = 1:m sum = sum + temp_cost(i)^2; end

J = (1/(2*m))*sum;

comeonsunny avatar May 21 '22 01:05 comeonsunny