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

📄 adaboost_te.m

📁 boost算法
💻 M
字号:
function [L,hits] = ADABOOST_te(adaboost_model,te_func_handle,test_set,...                                true_labels)%% ADABOOST TESTING%%  [L,hits] = ADABOOST_te(adaboost_model,te_func_handle,train_set,%                         true_labels)%%           'te_func_handle' is a handle to the testing function of a%           learning (weak) algorithm whose prototype is shown below.%%           [L,hits,error_rate] = test_func(model,test_set,sample_weights,true_labels)%                    model: the output of train_func%                    test_set: a KxD dimensional matrix, each of whose row is a%                        testing sample in a D dimensional feature space.%                    sample_weights:  a Dx1 dimensional vector, the i-th entry %                        of which denotes the weight of the i-th sample.%                    true_labels: a Dx1 dimensional vector, the i-th entry of which%                        is the label of the i-th sample.%                    L: a Dx1-array with the predicted labels of the samples.%                    hits: number of hits, calculated with the comparison of L and%                        true_labels.%                    error_rate: number of misses divided by the number of samples.%%           It is the corresponding testing %           module of the function that is specified in the training phase.%           'test_set' is a NxD matrix where N is the number of samples%           in the test set and D is the dimension of the feature space.%           'true_labels' is a Nx1 matrix specifying the class label of%           each corresponding sample's features (each row) in 'test_set'.%           'adaboost_model' is the model that is generated by the function%           'ADABOOST_tr'.%%           'L' is the likelihoods that are assigned by the 'ADABOOST_te'.%           'hits' is the number of correctly predicted labels.%%        Specific Properties That Must Be Satisfied by The Function pointed%        by 'func_handle'%        ------------------------------------------------------------------%% Notice: Labels must be positive integer values from 1 upto the number classes.%% Bug Reporting: Please contact the author for bug reporting and comments.%% Cuneyt Mertayak% email: cuneyt.mertayak@gmail.com% version: 1.0% date: 21/05/2007%hypothesis_n = length(adaboost_model.weights);sample_n = size(test_set,1);class_n = length(unique(true_labels));temp_L = zeros(sample_n,class_n,hypothesis_n);		% likelihoods for each weak classifier% for each weak classifier, likelihoods of test samples are collectedfor i=1:hypothesis_n	[temp_L(:,:,i),hits,error_rate] = te_func_handle(adaboost_model.parameters{i},...													 test_set,ones(sample_n,1),true_labels);	temp_L(:,:,i) = temp_L(:,:,i)*adaboost_model.weights(i);endL = sum(temp_L,3);hits = sum(likelihood2class(L)==true_labels);

⌨️ 快捷键说明

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