Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slroc
Home > sltoolbox > perfeval > slroc.m

slroc

PURPOSE ^

SLROC Computes the ROC

SYNOPSIS ^

function [thrs, fars, frrs] = slroc(scores, signs, thres, op)

DESCRIPTION ^

SLROC Computes the ROC

 $ Syntax $
   - [thrs, fars, frrs] = slroc(scores, signs, thres, op) 

 $ Arguments $
   - scores:           the scores representing the signal intensities
   - signs:            the signs representing the groundtruth (0 or 1)
   - thres:            the descriptor indicating how to sample the 
                       thresholds at which the rate is computed
   - op:               the option stating the attributes of the scores.
   - thrs:             the sampled threshold values
   - fars:             the false accept rates at the sampled thresholds
   - frrs:             the false reject rates at the sampled thresholds
 
 $ Description $
   - [thrs, fars, frrs] = slroc(scores, signs, thres, op) Computes the 
     ROC of a receiver from the scores and groudtruth signs. The argument 
     thres specifies the sampled thresholds at which the false accept 
     rate and false reject rate is evaluated. If thres is an integer, 
     say n, then n equal-interval integers from lowest to highest scores 
     are taken as samples. The thres can also be a vector containing the 
     sampled thresholds, which should be arranged in ascending order.
     op states the attributes of the scores, which
     takes either of the two values: 'high' or 'low'. If op is 'high', a 
     higher score indicates a better match; if op is 'low', a lower score
     indicates a better match. The cumulative score will be computed
     up to the number of all classes.
     For output, if n thresholds are sampled, then thrs, fars, and frrs
     for all n x 1 vectors, containing the sampled threshold values,
     and the corresponding false accept rates, and false reject rates.

 $ History $
   - Created by Dahua Lin on Jun 9th, 2005
   - Modified by Dahua Lin on May 1st, 2006
     - Base on the sltoolbox v4
   - Modified by Dahua Lin on Aug 8th, 2006
     - Base on slhistroc

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slhistroc SLHISTROC Computes the ROC curve from value histogram
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:

SOURCE CODE ^

0001 function [thrs, fars, frrs] = slroc(scores, signs, thres, op)
0002 %SLROC Computes the ROC
0003 %
0004 % $ Syntax $
0005 %   - [thrs, fars, frrs] = slroc(scores, signs, thres, op)
0006 %
0007 % $ Arguments $
0008 %   - scores:           the scores representing the signal intensities
0009 %   - signs:            the signs representing the groundtruth (0 or 1)
0010 %   - thres:            the descriptor indicating how to sample the
0011 %                       thresholds at which the rate is computed
0012 %   - op:               the option stating the attributes of the scores.
0013 %   - thrs:             the sampled threshold values
0014 %   - fars:             the false accept rates at the sampled thresholds
0015 %   - frrs:             the false reject rates at the sampled thresholds
0016 %
0017 % $ Description $
0018 %   - [thrs, fars, frrs] = slroc(scores, signs, thres, op) Computes the
0019 %     ROC of a receiver from the scores and groudtruth signs. The argument
0020 %     thres specifies the sampled thresholds at which the false accept
0021 %     rate and false reject rate is evaluated. If thres is an integer,
0022 %     say n, then n equal-interval integers from lowest to highest scores
0023 %     are taken as samples. The thres can also be a vector containing the
0024 %     sampled thresholds, which should be arranged in ascending order.
0025 %     op states the attributes of the scores, which
0026 %     takes either of the two values: 'high' or 'low'. If op is 'high', a
0027 %     higher score indicates a better match; if op is 'low', a lower score
0028 %     indicates a better match. The cumulative score will be computed
0029 %     up to the number of all classes.
0030 %     For output, if n thresholds are sampled, then thrs, fars, and frrs
0031 %     for all n x 1 vectors, containing the sampled threshold values,
0032 %     and the corresponding false accept rates, and false reject rates.
0033 %
0034 % $ History $
0035 %   - Created by Dahua Lin on Jun 9th, 2005
0036 %   - Modified by Dahua Lin on May 1st, 2006
0037 %     - Base on the sltoolbox v4
0038 %   - Modified by Dahua Lin on Aug 8th, 2006
0039 %     - Base on slhistroc
0040 %
0041 
0042 %% parse and verify the input arguments
0043 if nargin < 4
0044     raise_lackinput('slroc', 4);
0045 end
0046 if ~isequal(size(scores), size(signs))
0047     error('sltoolbox:sizmismatch', ...
0048         'The sizes of scores and signs are not match');
0049 end
0050 
0051 % the following two statements are disabled in the 2006-08-08 modification
0052 % since scores(signs) will automatic serialize the values
0053 % there is no need to write this statement, just a waste of time and mem
0054 % scores = scores(:);
0055 % signs = logical(signs(:));
0056 
0057 if numel(thres) == 1
0058     n = thres;
0059     highscore = max(max(scores));
0060     lowscore = min(min(scores));
0061     thrs = linspace(lowscore, highscore, n)';
0062 else
0063     thrs = thres(:);
0064 end
0065 
0066     
0067 
0068 %% compute
0069 scores_a = scores(signs);
0070 scores_r = scores(~signs);
0071 
0072 hist_a = histc(scores_a, thrs);
0073 hist_r = histc(scores_r, thrs);
0074 
0075 [thrs, fars, frrs] = slhistroc(hist_a, hist_r, thrs, op);
0076 
0077 
0078 
0079 
0080

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com