⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runadaboosting.m

📁 一个用matlab的实现的Adaboost_M1, 主要用运捆绑不同的分类器. boosting 算法的一种
💻 M
字号:
%%
% File Name: runAdaBoosing
% This is the "main" it runs the ada boost algorithm and for different sizes of
% training sets. It provides a graph of the errors according to the size of the
% training set.
%%
%!Important: run this commands in the Matlab "Command Window" before you run  
%open usps.mat;
%load usps.mat;

function runAdaBoosting(train,train_label,test,test_label)
disp('run adaboost with cycles=100');
step=100;
cycles=100;
for m=step:step:1000
    disp(m);
    boost=adaBoost(train(1:m,:),train_label(1:m),cycles);
    [errorTrain(m/step),errorTest(m/step)]=getError(boost,train(1:m,:),train_label(1:m),test,test_label);
end

% image figure No. 1
f1h = figure;   
% set various properties and display images
set(f1h,'units','normalized');  
set(f1h,'position',[0 0 0.5 1]); 
set(f1h,'numbertitle','off');
titleName='adaboost first work';
set(f1h,'name',titleName);
X = step : step : 1000 ;
plot(X,errorTrain,'r+:',X,errorTest,'bd-');
title('adaboost vs. size of train file','Fontsize',16);
xlabel('num of samples (on train file)');
ylabel('Errrors rate');
legend('error on train file','error on test file');
grid on;
clear errorTrain;
clear errorTest;
disp('run adaboost algorothm with different boosting');

step=20;
maxCycles=100;
for cycles=step:step:maxCycles
    disp(cycles);
    boost=adaBoost(train,train_label,cycles);
    [errorTrain(cycles/step),errorTest(cycles/step)]=getError(boost,train,train_label,test,test_label);
    clear boost;
end

 % image figure No. 2
f2h = figure;      
% set various properties and display images
set(f2h,'units','normalized');  
set(f2h,'position',[0 0 0.5 1]); 
set(f2h,'numbertitle','off');
set(f2h,'name',titleName);
X = step : step : maxCycles ;
plot(X,errorTrain,'r+:',X,errorTest,'bd-');
title('adaboost vs. boosting cycles','Fontsize',16);
xlabel('num of samples (on train file)');
ylabel('Errrors rate');
legend('error on train file','error on test file');
grid on;


         
        
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -