二分类 度量可分类程度指标Hindex IN ,matlab
function h = Hindex( pos,neg )
%HINDEX compute hindex for class 2 classification
% n-d will be fine
[Np,dp]=size(pos);
[Nn,dn]=size(neg);
Ppos=Np/(Np+Nn);
Pneg=Nn/(Np+Nn);
pos=pos';
neg=neg';
tmpall=zeros(dp,1);
for i=1:Np
tmpx=zeros(dp,1);
for j=1:dp
tmpx(j)=pos((i-1)*dp+j);
end
tmpall=tmpall+tmpx;
end
tmpall2=zeros(dn,1);
for i=1:Nn
tmpx2=zeros(dn,1);
for j=1:dn
tmpx2(j)=neg((i-1)*dn+j);
end
tmpall2=tmpall2+tmpx2;
end
X=(tmpall+tmpall2)/(Np+Nn);
Xp=tmpall/Np;
Xn=tmpall2/Nn;
sb=Ppos*(Xp-X)*((Xp-X)')+Pneg*(Xn-X)*((Xn-X)');
% sb matrics finished
% pos sw
partone=zeros(dp);
for i=1:Np
tmpx=zeros(dp,1);
for j=1:dp
tmpx(j)=pos((i-1)*dp+j);
end
partone=partone+(tmpx-Xp)*((tmpx-Xp)');
end
parttwo=zeros(dn);
for i=1:Nn
tmpx=zeros(dn,1);
for j=1:dn
tmpx(j)=neg((i-1)*dn+j);
end
parttwo=parttwo+(tmpx-Xn)*((tmpx-Xn)');
end
sw=Ppos*(1/Np)*partone+Pneg*(1/Nn)*parttwo;
h=det(sb)/det(sw);
end