forked from oliveirafhm/DR-Toolbox-Benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROCInterp.m
41 lines (39 loc) · 1.4 KB
/
ROCInterp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% Function name....: ROCInterp
% Date.............: July 04, 2016
% Author...........: Fabio Henrique, ([email protected])
% Description......:
% Interpolates ROC data using interp1 function
% Parameters.......:
% xIn -> False positive rate (array)
% yIn -> True positive rate (array)
% nSamples -> Out number of samples
% xLim -> Array of lower and upper x limits
% varargin:
% method -> Interpolation method (look intep1 matlab
% doc)(string)
% toPlot -> 0 (false); 1 (true)
% Return...........:
% xOut -> Uniformly spaced x values
% yOut -> Interpolated values
% uniqueXIn -> Unique values of xIn vector
% idxUniqueXIn -> Indexes of uniqueXIn
% Remarks..........:
%
function [xOut,yOut,uniqueXIn,idxUniqueXIn] = ROCInterp(xIn,yIn,nSamples,...
xLim,varargin)
method = varargin{1};
toPlot = varargin{2};
if isempty(method)
method = 'linear';
end
[uniqueXIn,idxUniqueXIn] = unique(xIn);
xOut = xLim(1):1/(nSamples-1):xLim(2);
yOut = interp1(uniqueXIn,yIn(idxUniqueXIn),xOut,method);
if toPlot == 1
figure;
plot(xIn,yIn,'o',xOut,yOut);
title('ROC Interpolation');
xlabel('False positive rate');
ylabel('True positive rate');
end
end