1function p = predict(theta, X) 2%PREDICT Predict whether the label is 0 or 1 using learned logistic 3%regression parameters theta 4% p = PREDICT(theta, X) computes the predictions for X using a 5% threshold at 0.5 (i.e., if sigmoid(theta'*x) >= 0.5, predict 1) 6 7m = size(X, 1); % Number of training examples 8 9% You need to return the following variables correctly 10p = zeros(m, 1); 11 12% ====================== YOUR CODE HERE ====================== 13% Instructions: Complete the following code to make predictions using 14% your learned logistic regression parameters. 15% You should set p to a vector of 0's and 1's 16% 17 18g = sigmoid(X*theta); 19for i = 1:size(X,1), if(g(i,1)>=0.5) p(i,1) = 1; end; end; 20disp(p); 21% ========================================================================= 22 23 24end 25 26