dallrgl - DAL with logistic loss and grouped L1 regularization Overview: Solves the optimization problem: [xx,bias] = argmin sum(log(1+exp(-yy.*(A*x+bias)))) + lambda*||x||_G1 where ||x||_G1 = sum(sqrt(sum(xx.^2))) (grouped L1 norm) Syntax: [ww,bias,status]=dallrgl(ww, A, yy, lambda, <opt>) Inputs: ww : initial solution (nn x 1) A : the design matrix A (mm,nn) yy : the target label vector (-1 or +1) (mm x 1) lambda : the regularization constant <opt> : list of 'fieldname1', value1, 'filedname2', value2, ... stopcond : stopping condition, which can be 'pdg' : Use relative primal dual gap (default) 'fval' : Use the objective function value (see dal.m for other options) Outputs: ww : the final solution (nn x 1) bias : the final bias term (scalar) status : various status values Copyright(c) 2009 Ryota Tomioka This software is distributed under the MIT license. See license.txt
0001 % dallrgl - DAL with logistic loss and grouped L1 regularization 0002 % 0003 % Overview: 0004 % Solves the optimization problem: 0005 % [xx,bias] = argmin sum(log(1+exp(-yy.*(A*x+bias)))) + lambda*||x||_G1 0006 % where 0007 % ||x||_G1 = sum(sqrt(sum(xx.^2))) 0008 % (grouped L1 norm) 0009 % 0010 % Syntax: 0011 % [ww,bias,status]=dallrgl(ww, A, yy, lambda, <opt>) 0012 % 0013 % Inputs: 0014 % ww : initial solution (nn x 1) 0015 % A : the design matrix A (mm,nn) 0016 % yy : the target label vector (-1 or +1) (mm x 1) 0017 % lambda : the regularization constant 0018 % <opt> : list of 'fieldname1', value1, 'filedname2', value2, ... 0019 % stopcond : stopping condition, which can be 0020 % 'pdg' : Use relative primal dual gap (default) 0021 % 'fval' : Use the objective function value 0022 % (see dal.m for other options) 0023 % Outputs: 0024 % ww : the final solution (nn x 1) 0025 % bias : the final bias term (scalar) 0026 % status : various status values 0027 % 0028 % Copyright(c) 2009 Ryota Tomioka 0029 % This software is distributed under the MIT license. See license.txt 0030 0031 function [ww,uu,status]=dallrgl(ww, A, yy, lambda, varargin) 0032 0033 opt=propertylist2struct(varargin{:}); 0034 opt=set_defaults(opt,'solver','nt',... 0035 'stopcond','pdg',... 0036 'blks',[]); 0037 0038 if isempty(opt.blks) 0039 opt.blks=size(ww,1)*ones(1,size(ww,2)); 0040 ww = ww(:); 0041 end 0042 0043 prob.floss = struct('p',@loss_lrp,'d',@loss_lrd,'args',{{yy}}); 0044 prob.fspec = {@gl_spec, opt.blks}; 0045 prob.dnorm = {@gl_dnorm, opt.blks}; 0046 prob.obj = @objdalgl; 0047 prob.softth = @gl_softth; 0048 prob.stopcond = ['stopcond_' opt.stopcond]; 0049 prob.ll = min(0,yy); 0050 prob.uu = max(0,yy); 0051 prob.Ac =[]; 0052 prob.bc =[]; 0053 prob.info = struct('blks',opt.blks); 0054 0055 if isequal(opt.solver,'cg') 0056 prob.hessMult = @hessMultdalgl; 0057 end 0058 0059 if isequal(opt.stopcond,'fval') 0060 opt.feval = 1; 0061 end 0062 0063 opt.aa = yy/2; 0064 0065 [mm,nn]=size(A); 0066 prob.mm = mm; 0067 prob.nn = nn; 0068 0069 [ww,uu,status]=dal(prob,ww,0,A,ones(mm,1),lambda,opt); 0070 0071 0072 if all(opt.blks==opt.blks(1)) 0073 ns=opt.blks(1); 0074 nc=length(ww)/ns; 0075 ww=reshape(ww, [ns,nc]); 0076 end