[Home]


RNNL2BLDA

A Matlab code for "Reverse nearest neighbors Bhattacharyya bound linear discriminant analysis for multimodal classification." (You could Right-Click [Code] , and Save, then you can download the whole matlab code.)


Reference

Guo Y R, Bai Y Q, Li C N, Shao Y H , Ye Y F,Jiang C Z. Reverse nearest neighbors Bhattacharyya bound linear discriminant analysis for multimodal classification.Applied Soft Computing Journal, 2020.

Main Function

function W = RNNL2BLDA(X,Y,t,knn) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Ref: "Reverse nearest neighbors Bhattacharyya bound linear discriminant analysis for multimodal classification" % Input: % X - the training samples; % Y - the labels corresponding to training samples; % t - the threshold parameter; % knn - the nearest neighbors parameter. % Ouput: % W:the project vectors; % Using Example: % X = rand(50,10); % Y = [ones(25,1);-ones(25,1)]; % t=7; % knn=9; % W = RNNL2BLDA(X,Y,t,knn); % Reference: % Guo Y R, Bai Y Q, Shao Y H, Li C N, Ye Y F,Jiang C Z. Reverse nearest neighbors Bhattacharyya bound linear discriminant analysis for multimodal classification. Applied Soft Computing Journal, 2020. % Version 2.0 -- Dec/2019 % Written by Yan-Ru Guo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% function begin .... %%%%%%%%%%: [nSmp,nFea] = size(X);%nFea是特征个数,nSmp是样本个数; mj=[];C_mean=zeros(nSmp,nFea); Sw = zeros(nFea,nFea); %%%%%%%%计算反向传播近邻RNN: [nSmp,~] = size(X); %nFea是特征个数,nSmp是样本个数; NN=zeros(nSmp,knn);nRj=[]; RNN=zeros(nSmp,nSmp); for j=1:nSmp [a,~]=find(Y==Y(j)); Nn=a(knnsearch(X(a,:),X(j,:),'dist','Euclidean','k',knn+1)); if isempty(Nn) NN(j,:)=0; else Nn(Nn(:,:)==j)=[]; NN(j,1:length(Nn))=Nn; end end for j=1:nSmp [b,~]= find(NN==j); b=[b;zeros(nSmp-length(b),1)]; RNN(:,j)=b; nj=length(find(RNN(:,j)~=0)); nRj=[nRj,nj]; end %%%%%%%%%%%%计算类内Sw: for j=1:nSmp nj=nRj(j); if nj>=t mj=[mj,nj]; CRNNj_mean=mean(X(RNN(RNN(:,j)~=0,j),:),1); C_mean(j,:)=CRNNj_mean; TempM = X(RNN(RNN(:,j)~=0,j),:) - repmat(CRNNj_mean,nj,1);%每个样本点到类心的距离 Sw = Sw + TempM'*TempM; %类内散度矩阵 end end DeltaB = 0; %%%%%%计算类间Sb及Delta: Sbt = zeros(nFea,nFea); for i = 1:nSmp for j = 1:nSmp if it if nRj(j)>t if Y(RNN(find(RNN(:,i)~=0,1),i))~= Y(RNN(find(RNN(:,j)~=0,1),j)) DeltaB = DeltaB + sqrt(nRj(i)* nRj(j))*norm(C_mean(i,:)-C_mean(j,:))^2; Sbt = Sbt + sqrt(nRj(i)* nRj(j))/sum(mj,2)*(C_mean(i,:)-C_mean(j,:))'*(C_mean(i,:)-C_mean(j,:)); end end end end end end if isempty(mj) Delta=0; else Delta = sum(mj,2)*DeltaB/4; end Sbt = -Sbt; S = Sbt + Delta*Sw; S = -S; S = (S+S')/2; [W,D] = eig(S); end
Contacts


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