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 slgetroc
Home > sltoolbox > perfeval > slgetroc.m

slgetroc

PURPOSE ^

SLGETROC Computes some point from ROC Curve

SYNOPSIS ^

function [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara)

DESCRIPTION ^

SLGETROC Computes some point from ROC Curve

 $ Syntax $
   - [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara)

 $ Arguments $
   - thrs:         the sampled threshold values
   - fars:         the false accept rates at the sampled thresholds
   - frrs:         the false reject rates at the sampled thresholds
   - item:         the items to be evaluated
   - itempara:     the extra parameter for the item
   - thr:          the threshold at which the specified point is reached
   - fa:           the false accept rate at the selected point
   - fr:           the false reject rate at the selected point
   
 $ Description $
   [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara) Computes 
   a required point from the ROC curves specified by thrs, fars, and 
   frrs. The requirement on the point is specified by item and itempara.
   \*
   \t   Table 1.  The Items of ROC Retrieval    \\
   \h      name     &    description            \\
          'ratio'   &  solves the point where fr / fa = itempara   \\
          'fixfa'   &  solves the point where fa = itempara        \\
          'fixfr'   &  solves the point where fr = itempara        \\
          'fixth'   &  solves the point where threshold = itempara \\
          'best'    &  finds the point where 
                       itempara * fa + (1 - itempara) * fr attains min. \\
   \*

 $ Remarks $
   - To increase accuracy, inverse-interpolation technique is used.

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

CROSS-REFERENCE INFORMATION ^

This function calls:
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
  • slignorevars SLIGNOREVARS Ignores the input variables
This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara)
0002 %SLGETROC Computes some point from ROC Curve
0003 %
0004 % $ Syntax $
0005 %   - [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara)
0006 %
0007 % $ Arguments $
0008 %   - thrs:         the sampled threshold values
0009 %   - fars:         the false accept rates at the sampled thresholds
0010 %   - frrs:         the false reject rates at the sampled thresholds
0011 %   - item:         the items to be evaluated
0012 %   - itempara:     the extra parameter for the item
0013 %   - thr:          the threshold at which the specified point is reached
0014 %   - fa:           the false accept rate at the selected point
0015 %   - fr:           the false reject rate at the selected point
0016 %
0017 % $ Description $
0018 %   [thr, fa, fr] = slgetroc(thrs, fars, frrs, item, itempara) Computes
0019 %   a required point from the ROC curves specified by thrs, fars, and
0020 %   frrs. The requirement on the point is specified by item and itempara.
0021 %   \*
0022 %   \t   Table 1.  The Items of ROC Retrieval    \\
0023 %   \h      name     &    description            \\
0024 %          'ratio'   &  solves the point where fr / fa = itempara   \\
0025 %          'fixfa'   &  solves the point where fa = itempara        \\
0026 %          'fixfr'   &  solves the point where fr = itempara        \\
0027 %          'fixth'   &  solves the point where threshold = itempara \\
0028 %          'best'    &  finds the point where
0029 %                       itempara * fa + (1 - itempara) * fr attains min. \\
0030 %   \*
0031 %
0032 % $ Remarks $
0033 %   - To increase accuracy, inverse-interpolation technique is used.
0034 %
0035 % $ History $
0036 %   - Created by Dahua Lin on Jun 10th, 2005
0037 %   - Modified by Dahua Lin on May 1st, 2006
0038 %     - Base on the sltoolbox v4
0039 %
0040 
0041 %% Parse and Verify
0042 if nargin < 4
0043     raise_lackinput('slgetroc', 5);
0044 end
0045 if ~isequal(size(thrs), size(fars)) || ~isequal(size(thrs), size(frrs))
0046     error('sltoolbox:sizmismatch', ...
0047         'The sizes of thrs, fars and frrs are not consistent');
0048 end
0049 thrs = thrs(:);
0050 fars = fars(:);
0051 frrs = frrs(:);
0052 
0053 % preprocessing (make it strictly monotonical)
0054 fars = make_mono(fars);
0055 frrs = make_mono(frrs);
0056 
0057 %% Compute
0058 usemethod = 'linear';
0059 switch item
0060     case 'ratio'
0061         ratios = frrs ./ max(fars, eps);
0062         if nargin < 5 || isempty(itempara)
0063             itempara = 1;
0064         end
0065         thr = interp1(ratios, thrs, itempara, usemethod);
0066     case 'fixfa'
0067         if nargin < 5 || isempty(itempara)
0068             itempara = 0.1;
0069         end
0070         thr = interp1(fars, thrs, itempara, usemethod);
0071     case 'fixfr'
0072         if nargin < 5 || isempty(itempara)
0073             itempara = 0.1;
0074         end
0075         thr = interp1(frrs, thrs, itempara, usemethod);
0076     case 'fixth'
0077         if nargin < 5 || isempty(itempara)
0078             error('You must specify the parameter for fixth item');
0079         end 
0080         thr = itempara;
0081     case 'best'
0082         if nargin < 5 || isempty(itempara)
0083             itempara = 0.5;
0084         end
0085         [mv, p] = min(itempara * fars + (1 - itempara) * frrs);
0086         slignorevars(mv);
0087         thr = thrs(p);
0088     otherwise
0089         error('sltoolbox:invalidarg', ...
0090             'Invalid item %s for slgetroc', item);
0091 end
0092 
0093 fa = interp1(thrs, fars, thr, usemethod);
0094 fr = interp1(thrs, frrs, thr, usemethod);
0095 
0096 
0097 function f = make_mono(f)
0098 
0099 df = diff(f);
0100 
0101 if f(end) >= f(1)
0102     df = max(df, eps);
0103 else
0104     df = min(df, -eps);
0105 end
0106 f = [f(1); f(1) + cumsum(df)];
0107 
0108 
0109 
0110 
0111

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

Contact us at files@mathworks.com