Cursera: machine learning ex2.

This commit is contained in:
2015-03-01 12:18:13 +04:00
parent 8dcb7d81a8
commit 32f8821b79
15 changed files with 1295 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
function p = predict(theta, X)
%PREDICT Predict whether the label is 0 or 1 using learned logistic
%regression parameters theta
% p = PREDICT(theta, X) computes the predictions for X using a
% threshold at 0.5 (i.e., if sigmoid(theta'*x) >= 0.5, predict 1)
m = size(X, 1); % Number of training examples
% You need to return the following variables correctly
p = zeros(m, 1);
% ====================== YOUR CODE HERE ======================
% Instructions: Complete the following code to make predictions using
% your learned logistic regression parameters.
% You should set p to a vector of 0's and 1's
%
h = sigmoid( X*theta );
p = round(h);
% =========================================================================
end