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