资源简介
超全的模式识别Matlab源程序,包括很多方面,希望对大家有用
代码片段和文件信息
function [test_targets E] = ada_boost(train_patterns train_targets test_patterns params)
% Classify using the AdaBoost algorithm
% Inputs:
% train_patterns - Train patterns
% train_targets - Train targets
% test_patterns - Test patterns
% Params - [NumberOfIterations Weak Learner Type Learner‘s parameters]
%
% Outputs
% test_targets - Predicted targets
% E - Errors through the iterations
%
% NOTE: Suitable for only two classes
%
[k_max weak_learner alg_param] = process_params(params);
[NiM] = size(train_patterns);
W = ones(1M)/M;
IterDisp = 10;
full_patterns = [train_patterns test_patterns];
test_targets = zeros(1 size(test_patterns2));
%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_patterns(: indices) train_targets(indices) full_patterns alg_param);
%Ek <- Training error of Ck
E(k) = sum(W.*(Ck(1:M) ~= train_targets));
if (E(k) == 0)
break
end
%alpha_k <- 1/2*ln(1-Ek)/Ek)
alpha_k = 0.5*log((1-E(k))/E(k));
%W_k+1 = W_k/Z*exp(+/-alpha)
W = W.*exp(alpha_k*(xor(Ck(1:M)train_targets)*2-1));
W = W./sum(W);
%Update the test targets
test_targets = test_targets + alpha_k*(2*Ck(M+1:end)-1);
if (k/IterDisp == floor(k/IterDisp))
disp([‘Completed ‘ num2str(k) ‘ boosting iterations‘])
end
end
test_targets = test_targets > 0;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 952782 2002-05-20 08:36 PR\About.bmp
文件 1892 2003-06-26 20:48 PR\Ada_Boost.m
文件 2815 2003-06-10 20:38 PR\ADDC.m
文件 4439 2003-08-31 20:47 PR\AGHC.m
文件 3397 2003-06-26 21:06 PR\Backpropagation_Batch.m
文件 5308 2003-06-26 21:06 PR\Backpropagation_CGD.m
文件 6494 2003-02-22 20:26 PR\Backpropagation_Quickprop.m
文件 5029 2003-02-22 20:42 PR\Backpropagation_Recurrent.m
文件 3334 2003-02-22 20:46 PR\Backpropagation_SM.m
文件 3117 2003-02-22 20:50 PR\Backpropagation_Stochastic.m
文件 1421 2003-03-05 19:07 PR\Balanced_Winnow.m
文件 3343 2003-04-02 20:27 PR\Bayesian_Model_Comparison.m
文件 588 2001-12-27 09:56 PR\Bhattacharyya.m
文件 3248 2003-03-09 22:07 PR\BIMSEC.m
文件 5599 2003-06-10 20:37 PR\C4_5.m
文件 905 2003-02-22 21:13 PR\calculate_error.m
文件 756 2003-02-18 17:57 PR\calculate_region.m
文件 3721 2003-11-06 22:06 PR\CART.m
文件 846 2003-02-22 21:36 PR\CARTfunctions.m
文件 5527 2003-02-22 21:45 PR\Cascade_Correlation.m
文件 902 2001-12-27 10:15 PR\Chernoff.m
文件 2745 2003-11-08 22:59 PR\Classification.txt
文件 1995 2003-02-22 21:48 PR\classification_error.m
文件 19454 2003-09-21 21:04 PR\classifier.m
文件 4520 2003-03-04 20:47 PR\classifier.mat
文件 26413 2004-07-18 20:28 PR\classifier_commands.m
文件 2448 2004-07-18 20:21 PR\classify_paramteric.m
文件 3507 2003-10-11 22:11 PR\click_points.m
文件 753 2003-08-07 11:49 PR\combinations.m
文件 2754 2003-03-09 22:09 PR\Competitive_learning.m
............此处省略151个文件信息
- 上一篇:SPWM的三相MMC的matlab仿真
- 下一篇:通信原理pcm编码及解码
评论
共有 条评论