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

📄 train_test_simple.m

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

global preprocess;
clear run;

% The statistics of dataset
num_class = length(preprocess.ClassSet);
class_set = preprocess.ClassSet;

% Extract the training and testing data
X_test = X(testindex, :);
Y_test = Y(testindex, :);
X_train = X(trainindex, :);
Y_train = Y(trainindex, :);
 
% Classify with Ensemble 
[Y_compute, Y_prob] = Classify(classifier, X_train, Y_train, 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;    

⌨️ 快捷键说明

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