[Home]

##### CLDA

A Matlab code for Capped norm linear discriminant analysis and its applications (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 norm linear discriminant analysis and its applications",Submitted.

##### Main Function

function [W] = CLDA(Data,FunPara,dim) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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.epsilon: Parameter epsilon in capped l_{2,1}-norm. % FunPara.MaxIter: Maximum iteration number. % 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 norm linear discriminant analysis and its applications". % Pei-Wei Ren, Chun-Na Li, Yuan-Hai Shao % Version 2.0 -- Jan/2021 % Written by Chun-Na Li (na1013na@163.com) %% epsilon = FunPara.epsilon; MaxIter = FunPara.MaxIter; delta = 10^-4; 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).^(-1))*Ind1(l); end S1 = HW*diag(F)*HW' + delta*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)^(-1))*Ind2(k); end S2 = HB*diag(G)*HB'; [W,D] = eig(S1,S2); D = diag(D); [~, 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