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

slcorrectrate

PURPOSE ^

SLCORRECTRATE Computes the correct rate of classification

SYNOPSIS ^

function cr = slcorrectrate(scores, clabels, qlabels, op, varargin)

DESCRIPTION ^

SLCORRECTRATE Computes the correct rate of classification

 $ Syntax $
   - cr = slcorrectrate(scores, clabels, qlabels, op, ...) 

 $ Arguments $
   - scores:           the scores to support the classification
   - clabels:          the labels of classes
   - qlabels:          the groundtruth of the labels of query samples
   - op:               the option of the score
   - cr:               the correct rate of the score-based classification

 $ Description $
   - cr = slcorrectrate(scores, clabels, slabels, op, ...) 
     Computes the classification correct rate. Suppose we want to 
     classify n samples into m classes, then scores will be an m x n 
     matrix, with the entry at i-th row, j-th column representing the 
     score of the j-th sample in the i-th class. 
     For op, it can take either of the two values: 'high' and 'low'. 
     If op is 'high' then it means that the sample will be classified 
     to the class where it has the highest score value, vice versa 
     for 'low'.
 
 $ History $
   - Created by Dahua Lin on Jun 10th, 2005
   - Modified by Dahua Lin on May 1st, 2005
     - To base on the sltoolbox v4.
   - Modified by Dahua Lin on Aug 9th, 2006
     - Extract slclassify as independent function and base on it
   - Modified by Dahua Lin on Aug 16th, 2006
     - Based on new slclassify to support multiple schemes

CROSS-REFERENCE INFORMATION ^

This function calls:
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
  • slclassify SLCLASSIFY Classifies a set of samples according to final scores
This function is called by:

SOURCE CODE ^

0001 function cr = slcorrectrate(scores, clabels, qlabels, op, varargin)
0002 %SLCORRECTRATE Computes the correct rate of classification
0003 %
0004 % $ Syntax $
0005 %   - cr = slcorrectrate(scores, clabels, qlabels, op, ...)
0006 %
0007 % $ Arguments $
0008 %   - scores:           the scores to support the classification
0009 %   - clabels:          the labels of classes
0010 %   - qlabels:          the groundtruth of the labels of query samples
0011 %   - op:               the option of the score
0012 %   - cr:               the correct rate of the score-based classification
0013 %
0014 % $ Description $
0015 %   - cr = slcorrectrate(scores, clabels, slabels, op, ...)
0016 %     Computes the classification correct rate. Suppose we want to
0017 %     classify n samples into m classes, then scores will be an m x n
0018 %     matrix, with the entry at i-th row, j-th column representing the
0019 %     score of the j-th sample in the i-th class.
0020 %     For op, it can take either of the two values: 'high' and 'low'.
0021 %     If op is 'high' then it means that the sample will be classified
0022 %     to the class where it has the highest score value, vice versa
0023 %     for 'low'.
0024 %
0025 % $ History $
0026 %   - Created by Dahua Lin on Jun 10th, 2005
0027 %   - Modified by Dahua Lin on May 1st, 2005
0028 %     - To base on the sltoolbox v4.
0029 %   - Modified by Dahua Lin on Aug 9th, 2006
0030 %     - Extract slclassify as independent function and base on it
0031 %   - Modified by Dahua Lin on Aug 16th, 2006
0032 %     - Based on new slclassify to support multiple schemes
0033 %
0034 
0035 %% parse and verify input arguments
0036 
0037 if nargin < 4
0038     raise_lackinput('slcorrectrate', 4);
0039 end
0040 
0041 
0042 %% Make decision
0043 
0044 decisions = slclassify(scores, clabels, op, varargin{:});
0045 
0046 %% Evaluate correct rate
0047 
0048 qlabels = qlabels(:)';
0049 cr = sum(decisions == qlabels) / length(qlabels);
0050 
0051 
0052 
0053 
0054 
0055 
0056

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

Contact us at files@mathworks.com