| function [tp, fp, p, n, perm, varargin] = vl_tpfp(labels, scores, varargin) |
| |
| |
| |
| |
|
|
| |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| opts.includeInf = false ; |
| opts.numNegatives = [] ; |
| opts.numPositives = [] ; |
| [opts, varargin] = vl_argparse(opts, varargin) ; |
|
|
| |
| labels = labels(:)' ; |
| scores = scores(:)' ; |
|
|
| |
| p = sum(labels > 0) ; |
| n = sum(labels < 0) ; |
|
|
| if ~isempty(opts.numPositives) |
| if opts.numPositives < p |
| warning('NUMPOSITIVES is smaller than the number of positives in LABELS.') ; |
| end |
| p = opts.numPositives ; |
| end |
|
|
| if ~isempty(opts.numNegatives) |
| if opts.numNegatives < n |
| warning('NUMNEGATIVES is smaller than the number of negatives in LABELS.') ; |
| end |
| n = opts.numNegatives ; |
| end |
|
|
| |
| [scores, perm] = sort(scores, 'descend') ; |
|
|
| |
| if opts.includeInf |
| stop = length(scores) ; |
| else |
| stop = max(find(scores > -inf)) ; |
| end |
| perm = perm(1:stop) ; |
| labels = labels(perm) ; |
|
|
| |
| |
| tp = [0 cumsum(labels > 0)] ; |
| fp = [0 cumsum(labels < 0)] ; |
|
|