Home > dal > s_test_lasso_sparse.m

s_test_lasso_sparse

PURPOSE ^

% Example of squared-loss-L1 DAL on a synthetic problem (sparse)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Example of squared-loss-L1 DAL on a synthetic problem (sparse)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Example of squared-loss-L1 DAL on a synthetic problem (sparse)
0002 
0003 m = 1024;
0004 n = 4096;
0005 % k = round(0.04*n);
0006 k = 160;
0007 A=randn(m,n);
0008 I=randperm(n);w0=zeros(n,1);w0(I(1:k))=sign(randn(k,1));
0009 bb=A*w0+0.01*randn(m,1);
0010 lambda=0.1*max(abs(A'*bb));
0011 
0012 lambda = lambda*[1 0.1 0.01 1e-3 1e-4];
0013 time   = zeros(size(lambda));
0014 xx     = zeros(n,length(lambda));
0015 t0     = cputime;
0016 xx1    = zeros(n,1);
0017 for ii=1:length(lambda)
0018   xx1=dalsql1(xx1,A,bb,lambda(ii),'solver','nt');
0019   xx(:,ii)=xx1;
0020   time(ii)=cputime-t0;
0021   sparse  =full(sum(abs(xx1)>0)/n);
0022   fprintf('lambda=%g sparsity=%g%% time=%g\n',lambda(ii), sparse*100, time(ii));
0023 end
0024

Generated on Sat 22-Aug-2009 22:15:36 by m2html © 2003