Home > @SVMClassifier > computeOutputs.m

computeOutputs

PURPOSE ^

function [outs] = computeOutputs(svmCl, examples)

SYNOPSIS ^

function [outs, prob] = computeOutputs(svmCl, examples)

DESCRIPTION ^

 function [outs] = computeOutputs(svmCl, examples)
   computes the classification outputs for the given examples

   Inputs:
       svmCl: trained svm classifier.
       examples: instance to be classified.
                 Number of Instances X Number of Features

   Outputs:
       outs: predicted classification outputs
       prob: probability estimates (a probability of each estimate
             classified to belong to the selected class)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [outs, prob] = computeOutputs(svmCl, examples)
0002 % function [outs] = computeOutputs(svmCl, examples)
0003 %   computes the classification outputs for the given examples
0004 %
0005 %   Inputs:
0006 %       svmCl: trained svm classifier.
0007 %       examples: instance to be classified.
0008 %                 Number of Instances X Number of Features
0009 %
0010 %   Outputs:
0011 %       outs: predicted classification outputs
0012 %       prob: probability estimates (a probability of each estimate
0013 %             classified to belong to the selected class)
0014 
0015 if ~isstruct(svmCl.trainedSVM),
0016     error('classifier is not trained');
0017 end
0018 
0019 %% Handle Cell Arrays
0020 if iscell(examples),
0021     examples = cell2mat(examples);
0022 end
0023 
0024 %% Compute Outs
0025 dummy = ones(size(examples, 1), 1);
0026 
0027 [outs, ~, p] = svmpredict(dummy, examples, svmCl.trainedSVM, svmCl.libSvmPrdOpts);
0028 
0029 prob = NaN;
0030 %fix returned probabilities (re arrange them) Only if -b option was used
0031 if numel(strfind(svmCl.libSvmPrdOpts,'-b 1')) ~= 0
0032     model = svmCl.trainedSVM;
0033     map = zeros(getNumClasses(svmCl),1);
0034     map(model.Label) = (1:getNumClasses(svmCl))';
0035     prob = p(:,map);
0036 end

Generated on Sun 29-Sep-2013 01:25:24 by m2html © 2005