Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = length(y)
- h = sigmoid(X*theta);
- J = (1/m)*(-y'*log(h) - (1 - y)'*log(1-h));
- J = (1/m)*(-y'*log(h) - (1-y)'*log(1-h)) + (lambda/2*m)*sum(theta(2,:).^2)
- % theta(2:) implies i am adding from 2nd element and not the first one
- grad = zeros(size(theta));
- grad = (1/m)*X'*(h - y);
- grad = (1/m)*X'*(h - y) + (lambda/m)*theta(2,:);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement