Skip to content

Commit

Permalink
improve logistic regression using chol
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Oct 30, 2013
1 parent 313011b commit 1c98036
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chapter04/logitReg.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [model, llh] = logitReg(X, t, lambda)
function [model, llh, U] = logitReg(X, t, lambda)
% logistic regression for binary classification (Bernoulli likelihood)
% Written by Mo Chen ([email protected]).
if nargin < 3
Expand All @@ -22,8 +22,9 @@
Xw = bsxfun(@times, X, sqrt(y.*(1-y)));
H = Xw*Xw';
H(dg) = H(dg)+lambda;
U = chol(H);
g = X*(y-t)'+lambda.*w;
p = -H\g;
p = -U\(U'\g);
wo = w;
while true
w = wo+p;
Expand All @@ -41,4 +42,4 @@
end
end
llh = llh(2:iter);
model.w = w;
model.w = w;

0 comments on commit 1c98036

Please sign in to comment.