function [F,M]=MI_mRMR(data,FC,delta)
%%%%ranking features with mRMR and mutual information %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% rank features based on mutual information and minimal redundancy and
% maximal revelance (mRMR) strategy.
% Note: mutual information in this algorithm is not the classical one. If
% features are categorical, MI is derived from Shannon's entropy. However,
% if features are numerical, MI becomes Neighborhood Mutual information or
% Fuzzy mutual information dependent on parameter "FC"
% Detailed information about mRMR, please refer to Hanchuan Peng, Fuhui Long, Chris Ding. Feature Selection Based on Mutual Information: Criteria of Max-Dependency, Max-Relevance, and Min-Redundancy. IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 27, NO. 8, AUGUST 2005.
% F is the ranking of features
% M is the corresponding significance of features
% FC is to set the fuzzy(F) or crisp(C) mutual information
% delta is the size of neighborhood
% Shuang An, Qinghua Hu Oct. 2008, Harbin Institute of Technology
% http://www.turbo.hit.edu.cn/members/huqinghua
[row,column]=size(data);
%%%%%%%%%%%%%compute the relation matrix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:column
col=i;
r=[];
eval(['ssr' num2str(col) '=[];']);
for j=1:row
a=data(j,col);
x=data(:,col);
if (FC=='F')
for m=1:length(x)
r(j,m)=kersim(a,x(m),deta);
end
elseif (FC=='C')
for m=1:length(x)
r(j,m)=kersim_crisp(a,x(m),deta);
end
end
end
eval(['ssr' num2str(col) '=r;']);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M=[]; % Save the significance of features
a=[]; % Save the ranking of features
attri=ones(1,column-1);
m=0;
t=1;
%%%%%%%%%%%%%%%Select the first features%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:column-1
r1=eval(['ssr' num2str(i)]);
r2=eval(['ssr' num2str(column)]);
P=mutuinfo1(r1,r2);
if(P>m)
m=P;
t=i;
end
a(1)=t;
M(1)=m;
end
attri(t)=0; %如果该特征被选中则将该特征在原数据集中的序号置0;当选择下一个特征时则跳过该特征
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=2:column-2 %Select the 2nd, 3rd,...features
m=-1;
for k=1:column-1
if (attri(k)==1)
r1=eval(['ssr' num2str(k)]);
r2=eval(['ssr' num2str(column)]);
P1=mutuinfo1(r1,r2); %mutual between features and decision
P2=0;
for j=1:i-1
r1=eval(['ssr' num2str(k)]);
r2=eval(['ssr' num2str(a(j))]);
K=mutuinfo1(r1,r2);
P2=P2+K;
end
P2=P2/(i-1); % the average mutual information between features
P=P1-P2; % the significance of features
if(P>m)
m=P; %save the maximal P
t=k;
end
end
end
a(i)=t;
M(i)=m;
attri(t)=0;
end
for i=1:column-1 %the last feature
if (attri(i)==1)
a=[a i];
end
end
%%%%% compute fuzzy mutual information %%%%%%%%%%%%%%%%%%%%%%%%%%%%
function S=mutuinfo1(M1,M2)
S1=entropy(M1);
S2=entropy(M2);
S3=fs_jointentropy(M1,M2);
S=S1+S2-S3;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% compute fuzzy information entropy%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function s=entropy(M)
[a,b]=size(M);
K=0;
for i=1:a
S(i)=-(1/a)*log2(sum(M(i,:))/a);
end
s=sum(S);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%compute fuzzy binary relation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function kersim=kersim(a,x,e)
if abs(a-x)>e
kersim=0;
else
if (e==0)
if (a==x)
kersim=1;
else
kersim=0;
end
else
kersim=1-abs(a-x)/e;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%compute crisp binary relation%%%%%%%%%%%%%%%%%%%%
function kersim=kersim_crisp(a,x,e)
if abs(a-x)>e
kersim=0;
else
kersim=1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%compute fuzzy joint information entropy %%%%%%%%%%%%%%%%%%%%%%%
function [S]=fs_jointentropy(M1,M2)
[a,b]=size(M1);
K=0;
for i=1:a
Si=-(1/a)*log2(sum(min(M1(i,:),M2(i,:)))/a);
K=K+Si;
Si=0;
end
S=K;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- 1
- 2
前往页