Thanks,
I edited AdaBoost to be able to get more than one learner and combine them. The goal is to compare it with fixed combiners like meanc, etc. One character of adaboost is to highlight the miss-classified points by giving them higher weights to be consider in the next step with more attention. I am trying to use this characteristic as well as combining different classifiers. But in the data set that I used this policy does not work. i.e. that the available fixed combinators work better that this kind of extension.
To solve the problem of under-sampling I tried to modify the weights such that:
sum_weight(correctly classified)=0.5
sum_weight(wrongly classified)=0.5
but it does not work too.
I look forward to hearing from you.
Thanks,
THIS IS MY EXTENSION:
function [W,V,alf] = adaboost(a,clasf,rule,verbose)
% clasf is a vector of classifiers
prtrace(mfilename);
%%INITIALISATION
if nargin < 4, verbose = 0; end
if nargin < 3, rule = []; end
if nargin < 2 || isempty(clasf), clasf = nmc; end
if nargin < 1 || isempty(a)
W = mapping(mfilename,{clasf,n,rule,verbose});
W = setname(W,’Adaboost’);
return
end
n = size(clasf,2);
[m,k,c] = getsize(a);
V = [];
laba = getlab(a);
%lablist = getlablist(a);
%laba = getnlab(a);
%p = getprior(a);
%a = dataset(a,laba); % use numeric labels for speed
%a = setprior(a,p);
u = ones(m,1)/m; % initialise object weights
alf = zeros(1,n); % space for classifier weights
if verbose > 0 && k == 2
figure(verbose);
scatterd(a);
end
%% generate n classifiers
for i = 1:n
b = gendatw(a,u,m); % sample training set
b = setprior(b,getprior(a)); % use original priors
w = b*stacked(clasf(i)); % train weak classifier
ra = a*w; % test weak classifier
if verbose && k == 2
plotc(w,1); drawnow
end
labc = labeld(ra);
diff = sum(labc~=laba,2)~=0; % objects erroneously classified
erra = sum((diff).*u); % weighted error on original dataset
if (erra < (1-1/c)) % if classifier better then random guessing…
alf(i) = 0.5*(log((1-erra)/erra) + log(c-1));
correct = find(diff==0); % find correctly classified objects
wrong = find(diff==1); % find incorrectly classified objects
u(correct) = u(correct)*exp(-alf(i)); % give them the ...
u(wrong) = u(wrong)*exp(alf(i)); % proper weights
u(correct) = 0.5* u(correct)./sum(u(correct)); % normalize weights
u(wrong) = 0.5* u(wrong)./sum(u(wrong)); % normalize weights
u = u./sum(u); % normalize weights
else
alf(i) = 0;
end
%w = setlabels(w,lablist); % restore original labels
if verbose
disp([erra alf(i) sum(alf)])
end
V = [V w]; % store all classifiers
end
%% combine and return
if isempty(rule)
W = wvotec(V,alf); % default is weighted combiner
else
W = traincc(a,V,rule); % otherwise, use user supplied combiner
end
if verbose > 0 && k == 2
plotc(W,’r’,3)
ee = a*W*testc;
title([’Error: ‘, num2str(ee)]);
end
return