lrds > lrds_cvx.m

lrds_cvx

PURPOSE ^

lrds_cvx - logistic regression with dual spectral regularization

SYNOPSIS ^

function [W, bias, z, status]=lrds_cvx(X, Y, lambda, bQuiet, precision)

DESCRIPTION ^

 lrds_cvx - logistic regression with dual spectral regularization
            for symmetric matrix inputs (using CVX)
 Syntax:
  [W, bias, z, status]=lrds_cvx(X, Y, lambda, bQuiet, precision)

 Inputs:
  X      : Input matrices.
           [C,C,n] array: Each X(:,:,i) assumed to be symmetric.
           [C^2,n] array: Each reshape(X(:,i), sqrt(size(X,1))) assumed to be symmetric.
  Y      : Binary lables. +1 or -1. [n,1] matrix. n is the number of samples.
  lambda : Regularization constant.
  bQuiet : binary. true suppresses outputs. (default)
  precision : precision used by CVX. See CVX manual. (optional)

 Outputs:
  W      : Weight matrix. [C,C] matrix.
  bias   : Bias term
  z      : Classifier outputs. [n,1] matrix.
  status : Status returned by CVX.

 Reference:
 "Classifying Matrices with a Spectral Regularization",
 Ryota Tomioka and Kazuyuki Aihara,
 Proc. ICML2007, pp. 895-902, ACM Press; Oregon, USA, June, 2007.
 http://www.machinelearning.org/proceedings/icml2007/papers/401.pdf

 CVX: Matlab Software for Disciplined Convex Programming  
 Michael Grant, Stephen Boyd, Yinyu Ye
 http://www.stanford.edu/~boyd/cvx/

 This software is distributed from:
 http://www.sat.t.u-tokyo.ac.jp/~ryotat/lrds/index.html

 Ryota Tomioka 2007.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [W, bias, z, status]=lrds_cvx(X, Y, lambda, bQuiet, precision)
0002 % lrds_cvx - logistic regression with dual spectral regularization
0003 %            for symmetric matrix inputs (using CVX)
0004 % Syntax:
0005 %  [W, bias, z, status]=lrds_cvx(X, Y, lambda, bQuiet, precision)
0006 %
0007 % Inputs:
0008 %  X      : Input matrices.
0009 %           [C,C,n] array: Each X(:,:,i) assumed to be symmetric.
0010 %           [C^2,n] array: Each reshape(X(:,i), sqrt(size(X,1))) assumed to be symmetric.
0011 %  Y      : Binary lables. +1 or -1. [n,1] matrix. n is the number of samples.
0012 %  lambda : Regularization constant.
0013 %  bQuiet : binary. true suppresses outputs. (default)
0014 %  precision : precision used by CVX. See CVX manual. (optional)
0015 %
0016 % Outputs:
0017 %  W      : Weight matrix. [C,C] matrix.
0018 %  bias   : Bias term
0019 %  z      : Classifier outputs. [n,1] matrix.
0020 %  status : Status returned by CVX.
0021 %
0022 % Reference:
0023 % "Classifying Matrices with a Spectral Regularization",
0024 % Ryota Tomioka and Kazuyuki Aihara,
0025 % Proc. ICML2007, pp. 895-902, ACM Press; Oregon, USA, June, 2007.
0026 % http://www.machinelearning.org/proceedings/icml2007/papers/401.pdf
0027 %
0028 % CVX: Matlab Software for Disciplined Convex Programming
0029 % Michael Grant, Stephen Boyd, Yinyu Ye
0030 % http://www.stanford.edu/~boyd/cvx/
0031 %
0032 % This software is distributed from:
0033 % http://www.sat.t.u-tokyo.ac.jp/~ryotat/lrds/index.html
0034 %
0035 % Ryota Tomioka 2007.
0036 
0037 
0038 if ~exist('bQuiet','var') | isempty(bQuiet)
0039   bQuiet = true;
0040 end
0041 
0042 if ~exist('precision','var') | isempty(precision)
0043   precision = 'default';
0044 end
0045 
0046 m = size(X,1);
0047 n = length(Y);
0048 
0049 cvx_begin sdp
0050 cvx_quiet(bQuiet);
0051 cvx_precision(precision);
0052 variable W(m,m) symmetric;
0053 variable U(m,m) symmetric;
0054 variable bias;
0055 variable z(n);
0056 minimize sum(log(1+exp(-z))) + lambda*trace(U);
0057 subject to
0058 for i=1:n
0059     Y(i)*(trace(W*X(:,:,i))+bias)==z(i);
0060 end
0061 U >= W;
0062 U >= -W;
0063 cvx_end
0064 status = cvx_status;
0065 
0066 if isempty(strfind(status,'Solved'))
0067   fprintf('CVX_STATUS [%s]. All coefficients set to zero.\n', status);
0068   W    = zeros(m,m);
0069   bias = 0;
0070 end

Generated on Sat 26-Apr-2008 15:48:23 by m2html © 2003