In the below code what is meant by grouptrain or what does it include? Also what is the difference between trainingset and grouptrain here?
1 次查看(过去 30 天)
显示 更早的评论
function [result] = multisvm(TrainingSet,GroupTrain,TestSet) %Models a given training set with a corresponding group vector and %classifies a given test set using an SVM classifier according to a %one vs. all relation. % %This code was written by Cody Neuburger cneuburg@fau.edu %Florida Atlantic University, Florida USA %This code was adapted and cleaned from Anand Mishra's multisvm function %found at http://www.mathworks.com/matlabcentral/fileexchange/33170-multi-class-support-vector-machine/
u=unique(GroupTrain); numClasses=length(u); result = zeros(length(TestSet(:,1)),1);
%build models for k=1:numClasses %Vectorized statement that binarizes Group %where 1 is the current class and 0 is all other classes G1vAll=(GroupTrain==u(k)); models(k) = svmtrain(TrainingSet,G1vAll); end
%classify test cases for j=1:size(TestSet,1) for k=1:numClasses if(svmclassify(models(k),TestSet(j,:))) break; end end result(j) = k; end
0 个评论
回答(1 个)
Pranay Patel
2016-6-29
As SVM is supervised learning model, GroupTrain includes labels of TrainingSet images while TrainingSet includes features extracted from those images in order. For example 8 images from img1 to img8: TrainingSet=[ 1 10;2 20;3 30;4 40;5 50;6 66;3 30;4.1 42]; GroupTrain=[1;1;2;2;3;3;2;2];
Here, feature extracted from img1 are 1 10 and its class label is 1, same for rest images.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!