You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

predict.m 793 B

8 years ago
123456789101112131415161718192021222324252627
  1. function 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. m = size(X, 1); % Number of training examples
  7. % You need to return the following variables correctly
  8. p = zeros(m, 1);
  9. % ====================== YOUR CODE HERE ======================
  10. % Instructions: Complete the following code to make predictions using
  11. % your learned logistic regression parameters.
  12. % You should set p to a vector of 0's and 1's
  13. %
  14. prob = sigmoid(X * theta);
  15. pos = find(prob >= 0.5);
  16. p(pos,1) = 1;
  17. % =========================================================================
  18. end

机器学习

Contributors (1)