分类器 好坏的评价参数求法

function [Sensitivity, Specificity, Accuracy, MCC, Presion] = ComputeEvaluationIndexes(Confusion_Matrix, Ci)
% param :   Confuse_Matrix 表示所要计算的混淆矩阵
% param :   Ci 表示我们只关心第i类的估计指标


%Step 1: calculate TP,TN,FP,FN
tp = Confusion_Matrix(Ci, Ci);


temp = Confusion_Matrix;
temp(Ci,:) =[];
fp = sum(temp,1);
fp =fp(1,Ci);


temp = Confusion_Matrix;
temp(:,Ci) =[];
fn = sum(temp,2);
fn = fn(Ci,1);
        
temp = Confusion_Matrix;
temp(:,Ci) =[];
temp(Ci,:)=[];        
tn = sum(diag(temp));


%Step 2: calculate SEN
Sensitivity = tp/(tp+fn);        
Specificity = tn/(tn+fp);
Presion = tp/(tp+fp);
Accuracy = (tp+tn)/(tp+tn+fp+fn);
MCC = (tp*tn - fp*fn)/sqrt((tp+fp)*(tp+fn)*(tn+fp)*(tn+fn));
disp('Sensitivity = ');
disp(Sensitivity);
disp('Specificity = ');
disp(Specificity);
disp('Accuracy = ');
disp(Accuracy);
disp('MCC = ');
disp(MCC);
disp('Presion = ');
disp(Presion);

你可能感兴趣的:(分类器 好坏的评价参数求法)