Home > @AdaBooster > computeOutputs.m

computeOutputs

PURPOSE ^

function [outs] = computeOutputs(ab, examples)

SYNOPSIS ^

function [outs, realOuts] = computeOutputs(ab, examples, extraArg)

DESCRIPTION ^

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

   Inputs:
       examples: set of example patterns to be classified
       extraArg: an extra argument to be used if needed

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [outs, realOuts] = computeOutputs(ab, examples, extraArg)
0002 % function [outs] = computeOutputs(ab, examples)
0003 %   computes the classification outputs of adaBoost for the given examples
0004 %
0005 %   Inputs:
0006 %       examples: set of example patterns to be classified
0007 %       extraArg: an extra argument to be used if needed
0008 
0009 if isempty(ab.weakCl)
0010     error('A weak classifier is not specified');
0011 end
0012 if isnan(ab.thresh) && ~ab.perfect
0013     error('AdaBoost classifier has not been trained');
0014 end
0015 
0016 if nargin == 1
0017     error('incorrect number of arguments');
0018 elseif nargin == 2
0019     extraArgs = {examples};
0020 else
0021     if iscell(extraArg),
0022         extraArgs = {examples, extraArg{:}}; %#ok<CCAT>
0023     else
0024         extraArgs = {examples, extraArg};
0025     end
0026 end
0027 
0028 wkClOuts = computeOutputs(ab.trndCls{1}, extraArgs{:});
0029 nExamples = numel(wkClOuts);
0030 realOuts = zeros(nExamples, getNumClasses(ab));
0031 sz = size(realOuts);
0032 rowInds = (1:nExamples)';
0033 realOuts(sub2ind(sz, rowInds, wkClOuts)) = ab.clsWeights(1);
0034 for i = 2:length(ab.clsWeights),
0035     wkClOuts = computeOutputs(ab.trndCls{i}, extraArgs{:});
0036     inds = sub2ind(sz, rowInds, wkClOuts);
0037     realOuts(inds) = realOuts(inds) + ab.clsWeights(i);
0038 end
0039 if getNumClasses(ab) == 2
0040     outsPos = (realOuts(:, getPosVal(ab)) - realOuts(:, getNegVal(ab))) >= ab.thresh;
0041     outs(outsPos) = getPosVal(ab);
0042     outs(~outsPos) = getNegVal(ab);
0043     outs = outs';
0044 else
0045     [~, outs] = max(realOuts, [], 2);
0046 end

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