% experiment 5: revise 2

iterationNum = 50;

%1NN
nnadatrerr = zeros(1, iterationNum);
nnadatserr = zeros(1, iterationNum);
weight = zeros(iterationNum, size(nfea_tr,2));
nnriv1trerr = zeros(1, iterationNum);
nnriv1tserr = zeros(1, iterationNum);
rivw1 = zeros(iterationNum, size(nfea_tr,2));
nnriv2trerr = zeros(1, iterationNum);
nnriv2tserr = zeros(1, iterationNum);
rivw2 = zeros(iterationNum, size(nfea_tr,2));

for t = 1:iterationNum
    [nnadatrerr(t), nnadatserr(t), weight(t,:)] = adaboostM1('nearest', nfea_tr, lab_tr, nfea_ts, lab_ts, t, 6);
    [nnriv1trerr(t), nnriv1tserr(t), rivw1(t,:)] = adaboostM1_revise1('nearest', nfea_tr, lab_tr, nfea_ts, lab_ts, t, 6);
    [nnriv2trerr(t), nnriv2tserr(t), rivw2(t,:)] = adaboostM1_revise2('nearest', nfea_tr, lab_tr, nfea_ts, lab_ts, t, 6);
end

figure;
x = 1:iterationNum;
plot(x, nnadatserr, '-xb', x, nnriv1tserr, '-or', x, nnriv2tserr, '-sg');
axis([1 iterationNum 0 0.2]);
title('AdaBoost Revise');
xlabel('iteration number');
ylabel('error rate');
legend( 'adaboost test error', 'revise1 test error', 'revise2 test error');

