a | b/predict.m | ||
---|---|---|---|
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 | |||
7 | m = size(X, 1); % Number of training examples |
||
8 | |||
9 | p = round(sigmoid(X * theta)); |
||
10 | |||
11 | end |