[Home]

##### CLDA

A Matlab code for Capped l_{2,1}-norm linear discriminant analysis (You could Right-Click [Code] , and Save, then you can download the whole matlab code.)

##### Reference

Jiakou Liu, Pei-Wei Ren, Xiong Xiong, Chun-Na Li, Yuan-Hai Shao"Capped l_{2,1}-norm linear discriminant analysis" Submitted 2020

##### Main Function

function [W] = CLDA(Data,FunPara,dim) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % Input: % Data.X: Data matrix. Each column vector of Data.X is a sample. % Data.Y: Data label vector. % FunPara.MaxIter: Maximum iteration number. % FunPara.epsilon: Parameter epsilon in capped l_{2,1}-norm. % dim: reduced dimension. % % % % % Eample: % Data.X = rand(2,20); % Data.Y = [ones(10,1);2*ones(10,1)]; % FunPara.MaxIter = 5; % FunPara.epsilon = 1; % dim = 1; % [W] = CLDA(Data,FunPara,dim) % Reference: % "Capped l_{2,1}-norm linear discriminant analysis". % Pei-Wei Ren, Chun-Na Li, Yuan-Hai Shao % Version 1.0 -- Aug/2020 % Written by Chun-Na Li(na1013na163.com) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MaxIter = FunPara.MaxIter; epsilon = FunPara.epsilon; delta = 10^-6; X = Data.X; Y = Data.Y; [n,N] = size(X); label = unique(Y); nCls = length(label); m_Cls = zeros(nCls,1); idxCls = cell(nCls,1); for k = 1:nCls idxCls{k} = find(Y==label(k)); m_Cls(k) = length(idxCls{k}); end M = mean(X,2); MCls = zeros(n,nCls); for k = 1:nCls MCls(:,k) = mean(X(:,idxCls{k}),2); end HB = zeros(n,nCls); HW = zeros(n,N); for k = 1:nCls HB(:,k) = sqrt(m_Cls(k))*(MCls(:,k) - M); HW(:,idxCls{k}) = X(:,idxCls{k}) - MCls(:,k); end W = eye(n,dim); for it = 1:MaxIter S1 = zeros(n,n); S2 = zeros(n,n); objtemp = 0; for l = 1:N if norm(W'*HW(:,l),2)<=epsilon Ind1(l) = 1; else Ind1(l) = 0; end F(l) = Ind1(l)/(norm(W'*HW(:,l),2) + delta); end S1 = HW*diag(F)*HW'; for k = 1:nCls if norm(sqrt(m_Cls(k))*W'*HB(:,k),2)<=epsilon Ind2(k) = 1; else Ind2(k) = 0; end G(k) = Ind2(k)/(norm(sqrt(m_Cls(k))*W'*HB(:,k),2) + delta); end S2 = HB*diag(G)*HB'; [W,D] = eig(S1,S2); W = orth(W); D = diag(D); eigIdx1 = find(D < 1e-5); eigIdx = [eigIdx1]; D(eigIdx) = []; W(:,eigIdx) = []; [~, index] = sort(D); W = W(:,index); D = D(index); W = W(:,1:min(dim,length(index))); end
##### Contacts

Any question or advice please email to na1013na@163.com or shaoyuanhai21@163.com.

• Last updated: Aug, 20120