How to plot the ROC curve

5 visualizzazioni (ultimi 30 giorni)
Natsu dragon
Natsu dragon il 3 Feb 2018
Commentato: FAS il 5 Feb 2018
Hello. I used this code for plotting the ROC curve:
% Ground truth
GT = imread('reference.tif');
GT = GT == 1; % convert to binary image
P = nnz(GT); % number of positive responses in ground truth
N = nnz(1-GT);
% responses
R = imread('data.tif');
% your thresholds
thresholds = [0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8];
% alternatively, use 100 thresholds between min(R) and max(R)
% thresholds = linspace(min(R(:)), max(R(:)));
% pre-allocate for speed
tp = nan(1, length(thresholds));
fp = nan(1, length(thresholds));
for i = 1:numel(thresholds)
t = thresholds(end-i+1); % thresholds from high to low as i increases
Rt = R > t; % thresholded response
tp(i) = nnz(Rt & GT);
fp(i) = nnz(Rt & ~GT);
end
% convert to rates
TPR = tp/P;
FPR = fp/N;
plot(FPR, TPR) % ROC
For the attached matlab.zip data it works, but for Results.zip it gave me an empty plot area.

Risposte (1)

RAHMANI nadir
RAHMANI nadir il 5 Feb 2018
;

Community Treasure Hunt

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

Start Hunting!

Translated by