Home > @RealAdaBooster > getRankedFeatures.m

getRankedFeatures

PURPOSE ^

GETRANKEDFEATURES return each feature used with its score

SYNOPSIS ^

function [ features ] = getRankedFeatures( cl )

DESCRIPTION ^

GETRANKEDFEATURES return each feature used with its score
   Inputs:
       cl : real adaboost instance
   Outputs:
       features: featureInfo struct sorted descendingly by score
% retrieve features from weak classifier

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ features ] = getRankedFeatures( cl )
0002 %GETRANKEDFEATURES return each feature used with its score
0003 %   Inputs:
0004 %       cl : real adaboost instance
0005 %   Outputs:
0006 %       features: featureInfo struct sorted descendingly by score
0007     %% retrieve features from weak classifier
0008     allFeatures = [];
0009     
0010     weakCls = cl.trndCls;
0011     scores = abs(cl.clsWeights);
0012     
0013     for i=1:length(weakCls)
0014         wcl = weakCls{i};
0015         wf = getFeaturesInfo(wcl);
0016         % assuming that weak classifier can emmit more than one feature
0017         for j=1:length(wf)
0018             wf(j).score = scores(i);
0019         end
0020         allFeatures = [allFeatures; wf];
0021     end
0022     
0023     %% get Accumulated score for each feature
0024     %sum features which have the same id;
0025     [~, ind] = sort([allFeatures.id]);
0026     allFeatures = allFeatures(ind);
0027     
0028     
0029     features = [];
0030     s = allFeatures(1).score;
0031     count = 1;
0032     for i=2:length(allFeatures)    
0033         if allFeatures(i).id ~= allFeatures(i-1).id
0034             allFeatures(i-1).score = s;
0035             allFeatures(i-1).count = count;
0036             features = [features; allFeatures(i-1)];
0037             s = 0;
0038             count = 0;
0039         end
0040         s = s + allFeatures(i).score;
0041         count = count + 1;
0042     end
0043     allFeatures(end).score = s;
0044     allFeatures(end).count = count;
0045     features = [features; allFeatures(end)];
0046     
0047     %% rank features based on score
0048     [~, ind]=  sort([features.score], 'descend');
0049     features = features(ind);
0050     
0051 end
0052

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