✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

⛄ 内容介绍

分类是数据挖掘研究范畴中为了解决分类问题而提出的方法,同时它也是一种重要的分析数据的技术.作为一种有效的科学研究工具,组合分类器在医疗诊断,手写体识别,人脸识别,推荐系统等领域有着广泛的应用.

⛄ 部分代码

% Example for adaboost.m

%

% Type "edit adaboost.m" to see the code

% Make training data of two classes "red" and "blue"

 % with 2 features for each sample (the position  x and y).

  angle=rand(200,1)*2*pi; l=rand(200,1)*40+30; blue=[sin(angle).*l cos(angle).*l];

  angle=rand(200,1)*2*pi; l=rand(200,1)*40;    red=[sin(angle).*l cos(angle).*l];

 % All the training data

  datafeatures=[blue;red];

  dataclass(1:200)=-1; dataclass(201:400)=1;

 % Show the data

  figure, subplot(2,2,1), hold on; axis equal;

  plot(blue(:,1),blue(:,2),'b.'); plot(red(:,1),red(:,2),'r.');

  title('Training Data');

 % Use Adaboost to make a classifier

  [classestimate,model]=adaboost('train',datafeatures,dataclass,50);

 % Training results

 % Show results

  blue=datafeatures(classestimate==-1,:); red=datafeatures(classestimate==1,:);

  I=zeros(161,161);

  for i=1:length(model)

      if(model(i).dimension==1)

          if(model(i).direction==1), rec=[-80 -80 80+model(i).threshold 160];

          else rec=[model(i).threshold -80 80-model(i).threshold 160 ];

          end

      else

          if(model(i).direction==1), rec=[-80 -80 160 80+model(i).threshold];

          else rec=[-80 model(i).threshold 160 80-model(i).threshold];

          end

      end

      rec=round(rec);

      y=rec(1)+81:rec(1)+81+rec(3); x=rec(2)+81:rec(2)+81+rec(4);

      I=I-model(i).alpha; I(x,y)=I(x,y)+2*model(i).alpha;    

  end

 subplot(2,2,2), imshow(I,[]); colorbar; axis xy;

 colormap('jet'), hold on

 plot(blue(:,1)+81,blue(:,2)+81,'bo');

 plot(red(:,1)+81,red(:,2)+81,'ro');

 title('Training Data classified with adaboost model');

 % Show the error verus number of weak classifiers

 error=zeros(1,length(model)); for i=1:length(model), error(i)=model(i).error; end 

 subplot(2,2,3), plot(error); title('Classification error versus number of weak classifiers');

 % Make some test data

  angle=rand(200,1)*2*pi; l=rand(200,1)*70; testdata=[sin(angle).*l cos(angle).*l];

 % Classify the testdata with the trained model

  testclass=adaboost('apply',testdata,model);

 % Show result

  blue=testdata(testclass==-1,:); red=testdata(testclass==1,:);

 % Show the data

  subplot(2,2,4), hold on

  plot(blue(:,1),blue(:,2),'b*');

  plot(red(:,1),red(:,2),'r*');

  axis equal;

  title('Test Data classified with adaboost model');

⛄ 运行结果

【adaboost分类】基于adaboost实现一维数据分类附matlab代码_Data

⛄ 参考文献

[1] 董庆伟. 基于Adaboost算法的不平衡数据集分类效果研究[J]. 长春师范大学学报, 2022, 41(6):4.

[2] 黄道, 何晋, 刘志愿,等. 分类算法adaboostM1和multiboostAB对草药数据分类的比较[J]. 中国新通信, 2014, 16(6):1.

[3] 胡燕祝, 王松. 一种基于AdaBoost算法的感知器网络数据分类方法:, CN109726767A[P]. 2019.

⛳️ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料