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

📄 test_validate.m

📁 一个matlab的工具包,里面包括一些分类器 例如 KNN KMEAN SVM NETLAB 等等有很多.
💻 M
字号:
function run = test_validate(D, classifier)

global preprocess;
clear run;

% The statistics of dataset
[X, Y, num_data, num_feature] = Preprocessing(D);
num_class = length(preprocess.ClassSet);
class_set = preprocess.ClassSet;

% Extract the training and testing data
X_test = X;
Y_test = Y;
testindex = 1:num_data;

% Classify with Ensemble 
[Y_compute, Y_prob] = Classify(classifier, [], [], X_test, Y_test, num_class);      
run.Y_compute = Y_compute; run.Y_prob = Y_prob; run.Y_test = Y_test;
  
% Aggregate the predictions in a shot
if (preprocess.ShotAvailable == 1), [Y_compute, Y_prob, Y_test] = AggregatePredByShot(Y_compute, Y_prob, Y_test, testindex); end;  
  
% Report the performance
[run.YY, run.YN, run.NY, run.NN, run.Prec, run.Rec, run.F1, run.Err] = CalculatePerformance(Y_compute, Y_test, class_set);
if ((preprocess.ComputeMAP == 1) && (length(preprocess.OrgClassSet) == 2)),
      TrueYprob = Y_prob .* (Y_compute == 1)  + (1 - Y_prob) .* (Y_compute ~= 1);
      run.AvgPrec = ComputeAP(TrueYprob, Y_test, class_set);
      run.BaseAvgPrec = ComputeRandAP(Y_test, class_set);       
      fprintf('AP:%f, Base:%f\n', run.AvgPrec, run.BaseAvgPrec);
end;    

run.Y_pred = zeros(length(testindex), 4);
run.Y_pred(:, 1) = (1:num_data)';
run.Y_pred(:, 2) = run.Y_prob; 
run.Y_pred(:, 3) = run.Y_compute; 
run.Y_pred(:, 4) = run.Y_test;

⌨️ 快捷键说明

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