1
0
Fork 0
This repository has been archived on 2019-12-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coursera-ml-007-exercises/ex2/predict.m

29 lines
757 B
Mathematica
Raw Normal View History

2014-10-13 22:56:53 +02:00
function p = predict(theta, X)
2014-10-14 10:14:29 +02:00
%PREDICT Predict whether the label is 0 or 1 using learned logistic
2014-10-13 22:56:53 +02:00
%regression parameters theta
2014-10-14 10:14:29 +02:00
% p = PREDICT(theta, X) computes the predictions for X using a
2014-10-13 22:56:53 +02:00
% 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
2014-10-14 10:14:29 +02:00
% your learned logistic regression parameters.
2014-10-13 22:56:53 +02:00
% You should set p to a vector of 0's and 1's
%
2014-10-14 10:14:29 +02:00
p = sigmoid(X * theta) > 0.5;
2014-10-13 22:56:53 +02:00
% =========================================================================
end