• 大小: 14.51MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-20
  • 语言: Matlab
  • 标签: matlab  BP  adaboost  

资源简介

使用matlab训练集成分类器,这里使用的是BP网络,也可以很方便地改为其他分类器,与单个BP分类器相比,正确率由87%上升到97.9,有明显地提高。

资源截图

代码片段和文件信息

function [L hits] = AdaBoost_te(adaboost_modelte_func_handletest_settrue_labels)

hypothesis_n = length(adaboost_model.weights);   % 集成分类器中分类器的个数

sample_n = size(test_set2);   % 样本数

class_n = size(true_labels1);  % class_n = length(unique(true_labels));
temp_L = zeros(class_nsample_nhypothesis_n);   % likelihoods for each weak classifier  
  
% for each weak classifier likelihoods of test samples are collected  
for i=1:hypothesis_n  

% temp_L : 分类结果, hits: 正确率, error_rate: 错误率(与样本权重有关,不过这里样本权重均为1,ones(sample_n1))
    [temp_L(::i) hits error_rate] = te_func_handle(adaboost_model.parameters{i}test_setones(sample_n1)true_labels);  
    
    % 把每一个分类器的 分类结果 * 分类器的权重 最后把各个分类器的结果相加,得到最终的分类结果
    temp_L(::i) = temp_L(::i)*adaboost_model.weights(i);  

end  

L = sum(temp_L3);   % 最终的分类结果为 L

hits = sum(vec2ind(L) == vec2ind(true_labels)); % 集成分类器正确分类的个数。

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-27 21:41  集成分类器Adaboost\
     文件        1134  2018-04-15 19:50  集成分类器Adaboost\AdaBoost_te.m
     文件        1718  2018-04-15 19:38  集成分类器Adaboost\AdaBoost_tr.m
     文件    14322325  2018-01-23 23:17  集成分类器Adaboost\Batch.mat
     文件        2105  2018-07-27 21:03  集成分类器Adaboost\BP.m
     文件        4678  2018-04-15 19:50  集成分类器Adaboost\Chairman_Ensemble.m
     文件        1574  2018-07-27 21:39  集成分类器Adaboost\Main.m
     文件         567  2018-04-15 19:50  集成分类器Adaboost\Threshold_te.m
     文件         955  2018-04-15 19:21  集成分类器Adaboost\Threshold_tr.m
     文件      941794  2018-07-27 20:04  集成分类器Adaboost\传感器数据库汇总.docx
     文件         185  2018-07-27 21:48  集成分类器Adaboost\说明.txt

评论

共有 条评论