-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaskerplot.m
More file actions
executable file
·97 lines (88 loc) · 2.07 KB
/
askerplot.m
File metadata and controls
executable file
·97 lines (88 loc) · 2.07 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%ASKERPLOT Plot FP and FN
%
% ASKERPLOT(E)
% ASKERPLOT(W,A)
%
% INPUT
% E ROC curve obtained from E = A*W*DD_ROC
% W Trained one-class classifier
% A Dataset
%
% DESCRIPTION
% Plot the false positive and false negative rate as function of the
% thresholds on the output of the classifier W. Input parameter E is
% typically obtained using:
% E = A*W*DD_ROC
%
% SEE ALSO
% plotroc, dd_error, dd_roc
% Copyright: D.M.J. Tax, D.M.J.Tax@prtools.org
% Faculty EWI, Delft University of Technology
% P.O. Box 5031, 2600 GA Delft, The Netherlands
function askerplot(e,varargin)
% default settings:
fs = 16;
lw = 2;
% First check if we have the 'W,A' input or the 'E' input:
w = [];
if nargin>1
% get the second input argument...
a = varargin{1};
% and check if it is a dataset:
if isdataset(a) && ismapping(e)
if isocset(a)
w = e;
% then the first argument should be a classifier:
if ~isocc(w)
error('Now the first argument should be a OC classifier');
end
e = a*w*dd_roc;
% remove the second argument:
N = length(varargin);
if N<=2
varargin = {};
else
varargin = varargin(3:N);
end
else
error('I am expecting a one-class dataset');
end
else % did I reverse the dataset and mapping?
askerplot(a,e); return;
end
else
error('I am expecting ASKERPLOT(W,A)');
end
% Check if we got the new error structure containing an error and
% threshold field:
if isfield(e,'err')
if ~isfield(e,'thresholds')
error('The structure E should have an "err" and "thresholds" field.');
end
thresholds = e.thresholds;
e = e.err;
else
thresholds = [];
end
% transpose e if required:
if size(e,1)==2
e = e';
end
% and here we plot:
if isempty(thresholds)
h = semilogy(e(:,1),'r-');
set(h,'linewidth',lw);
hold on;
h = semilogy(e(:,2),'b-');
set(h,'linewidth',lw);
else
thresholds=thresholds(2:end);
h = semilogy(thresholds,e(:,1),'r-');
set(h,'linewidth',lw);
hold on;
h = semilogy(thresholds,e(:,2),'b-');
set(h,'linewidth',lw);
end
xlabel('Thresholds','fontsize',fs);
ylabel('FP (blue) and FN (red)','fontsize',fs);
grid on;