Should sensivity and specificity values always be reverse in Matlab?

1 view (last 30 days)
I want to compare several methods by using sensivity and specififcity (Measures for performance evaluation) ,
I wrote these codes based on their formula that I studied in wikipedia
sensivity computaion function (rforest is the resault of random forest classifier and ytest is the test labels)
function [SVrforest] = allsensivitydata(rforest,ytest)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
test_count=size(ytest,1);
tp_rf=0;tn_rf=0;fp_rf=0;fn_rf=0;
for i=1:test_count
if(rforest(i)==1 && ytest(i)==1)
tp_rf=tp_rf+1;
end
if(rforest(i)==2 && ytest(i)==2)
tn_rf=tn_rf+1;
end
if(rforest(i)==2 && ytest(i)==1)
fp_rf=fp_rf+1;
end
if(rforest(i)==1 && ytest(i)==2)
fn_rf=fn_rf+1;
end
end
SVrforest=(tp_rf)/(tp_rf+fn_rf);
end
specificity computation function:
function [SPrforest] = allspecificitydata(rforest, ytest)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
test_count=size(ytest,1);
tp_rf=0;tn_rf=0;fp_rf=0;fn_rf=0;
for i=1:test_count
if(rforest(i)==1 && ytest(i)==1)
tp_rf=tp_rf+1;
end
if(rforest(i)==2 && ytest(i)==2)
tn_rf=tn_rf+1;
end
if(rforest(i)==2 && ytest(i)==1)
fp_rf=fp_rf+1;
end
if(rforest(i)==1 && ytest(i)==2)
fn_rf=fn_rf+1;
end
end
SPrforest=(tn_rf)/(tn_rf+fp_rf);
end
I searched and I think sensivity and specivity's range is [0 1], but my question Is that for high sensivity value ,should It's specificity always obtain low value, I mean their values should always be reverse?
forexample : for a classifier sensivity=1 and specificity=0.75 or another example sensivity=0 and specificity=54 Is It correct?
should I change the codes?

Answers (0)

Categories

Find more on Wind Power in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!