📄 basicroc.m
字号:
function [tp , fp , threshold] = basicroc(y , f , options)
%
%[tp , fp , threshold] = basicroc(y , f , [positive]);
%
% Return the true positive rate, the false positive rate and the threshold
%
%
% Author : S閎astien PARIS : sebastien.paris@lsis.org
% ------- Date : 04/09/2006
if nargin < 3
options.positive = 1;
options.nbstep = 100;
end
if (~any(strcmp(fieldnames(options) , 'positive')))
options.positive = 1;
end
if (~any(strcmp(fieldnames(options) , 'nbstep')))
options.nbstep = 100;
end
yunique = unique(y);
bin = histc(y , yunique);
index = (yunique==options.positive);
P = bin(index); %(y = positive)
N = sum(bin(~index)); %(y = else)
minf = min(f);
maxf = max(f);
stepf = (maxf - minf)/(options.nbstep - 3);
threshold = (maxf:-stepf:minf);
tp = zeros(1 , options.nbstep - 2);
fp = zeros(1 , options.nbstep - 2);
co = 1;
for t = threshold
ind = (y(f>threshold(co))==options.positive);
tp(co) = sum(ind)/P;
fp(co) = sum(~ind)/N;
co = co + 1;
end
tp = [0 , tp , 1];
fp = [0 , fp , 1];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -