code shown here 我正在尝试实现SVM进行分类。目标是输出功率信号(.wav文件)的正确原点网格。网格标题为A-I,训练集共有93个信号,49个练习信号。我有一个93x10x36的特征向量矩阵。有谁知道我为什么会出现错误? TrainCorrectGrid和Training_Cepstrum1都有93行,所以我不明白问题是什么。任何帮助是极大的赞赏。
这里显示了multisvm函数:
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 :(得分:0)
SVM通常是一对一或一对所有分类器。然而,存在调整它们以实现多类分类的方法。
This包实现了一种这样的方式。
以下是使用包
的示例代码TrainingSet=[ 1 10;2 20;3 30;4 40;5 50;6 66;3 30;4.1 42];
TestSet=[3 34; 1 14; 2.2 25; 6.2 63];
GroupTrain=[1;1;2;2;3;3;2;2];
results = multisvm(TrainingSet, GroupTrain, TestSet);
disp('multi class problem');
disp(results);