• 大小: 914KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-20
  • 语言: Matlab
  • 标签:

资源简介

matlab分类器源码(包括遗传算法等等)

资源截图

代码片段和文件信息

function D = ada_boost(train_features train_targets params region);

% Classify using the AdaBoost algorithm
% Inputs:
%  features - Train features
% targets - Train targets
% Params - [NumberOfIterations Weak Learner Type Learner‘s parameters]
% region - Decision region vector: [-x x -y y number_of_points]
%
% Outputs
% D - Decision sufrace
%
% NOTE: This algorithm is very tuned to the 2D nature of the toolbox!

[k_max weak_learner alg_param] = process_params(params);

[NiM] = size(train_features);
D   = zeros(region(5));
W   = ones(1M)/M;
IterDisp = 10;

%Find where the training features fall on the decision grid
N           = region(5);
mx          = ones(N1) * linspace (region(1)region(2)N);
my          = linspace (region(3)region(4)N)‘ * ones(1N);
flatxy      = [mx(:) my(:)]‘;
train_loc = zeros(1M);
for i = 1:M
   dist = sqrt(sum((flatxy - train_features(:i)*ones(1N^2)).^2));
   [m train_loc(i)] = min(dist);
end

%Do the AdaBoosting
for k = 1:k_max
   %Train weak learner Ck using the data sampled according to W:
   %...so sample the data according to W
   randnum = rand(1M);
   cW    = cumsum(W);
   indices = zeros(1M);
   for i = 1:M
      %Find which bin the random number falls into
      loc = max(find(randnum(i) > cW))+1;
      if isempty(loc)
         indices(i) = 1;
      else
         indices(i) = loc;
      end
   end
   
   %...and now train the classifier
   Ck  = feval(weak_learner train_features(: indices) train_targets(indices) alg_param region);
   Ckl  = Ck(:);
   
   %Ek <- Training error of Ck 
   Ek = sum(W.*(Ckl(train_loc)‘ ~= train_targets));
   
   if (Ek == 0)
      break
   end
   
   %alpha_k <- 1/2*ln(1-Ek)/Ek)
   alpha_k = 0.5*log((1-Ek)/Ek);
   
   %W_k+1 = W_k/Z*exp(+/-alpha)
   W  = W.*exp(alpha_k*(xor(Ckl(train_loc)‘train_targets)*2-1));
   W  = W./sum(W);
   
   %Update the decision region
   D  = D + alpha_k*(2*Ck-1);
   
   if (k/IterDisp == floor(k/IterDisp))
      disp([‘Completed ‘ num2str(k) ‘ boosting iterations‘])
   end
   
end

D = D>0;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件      952782  2002-05-20 08:36  About.bmp
     文件        2137  2002-06-25 09:28  Ada_Boost.m
     文件        3004  2002-02-18 13:25  ADDC.m
     文件        4318  2002-03-20 22:43  AGHC.m
     文件        3266  2002-03-21 09:29  Backpropagation_Batch.m
     文件        5183  2002-03-21 09:34  Backpropagation_CGD.m
     文件        6448  2002-03-21 09:31  Backpropagation_Quickprop.m
     文件        4963  2002-03-21 09:34  Backpropagation_Recurrent.m
     文件        3216  2002-03-21 09:33  Backpropagation_SM.m
     文件        2986  2002-03-21 09:33  Backpropagation_Stochastic.m
     文件        1377  2002-03-21 09:38  Balanced_Winnow.m
     文件        3248  2002-03-24 11:32  Bayesian_Model_Comparison.m
     文件         588  2001-12-27 09:56  Bhattacharyya.m
     文件        3298  2002-03-21 09:37  BIMSEC.m
     文件        5984  2002-06-30 00:02  C4_5.m
     文件         758  2001-12-24 16:34  calculate_error.m
     文件        1060  2001-02-22 13:06  calculate_region.m
     文件        4104  2002-03-20 22:43  CART.m
     文件         846  2002-02-09 22:54  CARTfunctions.m
     文件        5443  2002-03-21 09:39  Cascade_Correlation.m
     文件         902  2001-12-27 10:15  Chernoff.m
     文件        1528  2002-02-14 22:59  chess.mat
     文件        2837  2002-10-11 12:55  Classification.txt
     文件        1995  2002-09-18 20:40  classification_error.m
     文件      300868  2005-11-29 13:36  Classification_Toolbox.pdf
     文件       18308  2002-12-02 19:11  classifier.m
     文件        4328  2002-03-09 23:59  classifier.mat
     文件       24730  2002-12-02 21:10  classifier_commands.m
     文件        2926  2002-02-14 22:59  click_points.m
     文件       86112  2002-02-14 22:59  clouds.mat
     文件        2842  2002-03-21 09:36  Competitive_learning.m
............此处省略133个文件信息

评论

共有 条评论

相关资源