Permalink
Browse files

Calculate gradient for logistic regression

  • Loading branch information...
1 parent fcbfde9 commit c5febe972107559d793fe07b9c57200271ba886b Merouane Atig committed Oct 29, 2011
Showing with 3 additions and 0 deletions.
  1. +3 −0 mlclass-ex2/costFunction.m
@@ -22,6 +22,9 @@
htheta = sigmoid(X * theta);
J = 1 / m * sum(-y .* log(htheta) - (1 - y) .* log(1 - htheta));
+for i = 1:size(theta, 1)
+ grad(i) = 1 / m * sum((htheta - y) .* X(:, i));
+end

0 comments on commit c5febe9

Please sign in to comment.