# How to plot the ROC curve

5 visualizzazioni (ultimi 30 giorni)
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 = GT == 1; % convert to binary image
P = nnz(GT); % number of positive responses in ground truth
N = nnz(1-GT);
% responses
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.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

RAHMANI nadir il 5 Feb 2018
;
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
FAS il 5 Feb 2018
...

Accedi per commentare.

### Categorie

Scopri di più su Detection in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by