Created
May 8, 2013 05:36
-
-
Save taterbase/5538459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function J = costFunctionJ(X, y, theta) | |
% X is the "design matrix" containg our training examples | |
% y is the class labels | |
m = size(X,1); % numbedr of training examples | |
predictions = X*theta; % predictions of hypothesis on all m examples | |
sqrErrors = (predictions - y) .^2; % squared errors | |
J= 1/(2*m) * sum(sqrErrors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment