[Home]

##### GCLDA

A Matlab code for Generalized capped \$l_{2,q}\$ norm linear discriminant analysis with regularization (You could Right-Click [Code] , and Save, then you can download the whole matlab code.)

##### Reference

Chun-Na Li, Pei-Wei Ren, Yan-Ru Guo, Ya-Fen Ye, Yuan-Hai Shao, "Generalized capped \$l_{2,q}\$ norm linear discriminant analysis with regularization".

##### Main Function

function [W] = GCLDA(Data,FunPara,dim) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [W] = GCLDA(Data,FunPara,dim) %% % % % % Input: % Data.X: Data matrix. Each column vector of Data.X is a sample. % Data.Y: Data label vector. % FunPara.q: Parameter q in capped l_{2,q}-norm. % FunPara.epsilon: Parameter epsilon in capped l_{2,q}-norm. % FunPara.sigm：Regularization parameter % FunPara.MaxIter: Maximum iteration number. % dim: reduced dimension. % % % % % Eample: % Data.X = rand(2,20); % Data.Y = [ones(10,1);2*ones(10,1)]; % FunPara.q = 1; % FunPara.epsilon = 1; % FunPara.sigm = 1; % FunPara.MaxIter = 5; % dim = 1; % [W] = GCLDA(Data,FunPara,dim) % Reference: % "Generalized capped \$l_{2,q}\$ norm linear discriminant analysis with regularization". % Chun-Na Li, Pei-Wei Ren, Yan-Ru Guo, Ya-Fen Ye, Yuan-Hai Shao % Version 1.0 -- Jan/2021 % Written by Chun-Na Li (na1013na@163.com) %% MaxIter = FunPara.MaxIter; epsilon = FunPara.epsilon; sigm = FunPara.sigm; q = FunPara.q; 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) = ((norm(W'*HW(:,l),2) + delta).^(q-2))*Ind1(l); end S1 = HW*diag(F)*HW' + sigm*eye(n); 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) = ((norm(sqrt(m_Cls(k))*W'*HB(:,k),2) + delta)^(q-2))*Ind2(k); end S2 = HB*diag(G)*HB'; [W,D] = eig(S1,S2); 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: Jan, 2021