使用SVM训练我的数据集 [英] Using SVM to train my Dataset
问题描述
为了更好地理解支持向量机如何在MATLAB中工作的概念,我建议你简要阅读这非常重要的链接。
To understand well the concept behind how Support Vector Machine works in MATLAB, I advised you to read briefly THIS VERY IMPORTANT LINK.
我试图应用相同的概念,但我有不同的火车组测试集。
I am trying to apply the same concept but I have different train set and test set.
更精确:
我的列车集指的是被命名为 C2res {1} ,其中最后一个等于:
My train set refers to be named as C2res{1} where this last is equal to:
C2res{1} =
1.0e-05 *
Columns 1 through 10
0.5341 0.5822 0.6185 0.7555 0.7369 0.7131 0.5985 0.6483 0.5668 0.6620
Columns 11 through 12
0.6523 0.6097
我的测试集指的是 C2res {2} ,其中最后一个具有相同形式的C2res {1}但是具有dif不确定的价值...
My test set refers to be named as C2res{2} where this last has the same form of C2res{1} but with different values...
然后,我使用了上述链接中使用的概念:
Then, I used the concept used in the above link:
XTrain = [C2res{1}];
XTest = [C2res{2}];
label = [ones(size(C2res{1},2),1)];
SVMStruct = svmtrain(XTrain , label, 'kernel_function', 'linear');
Group = svmclassify(SVMStruct, XTest);
但不幸的是我总是收到如下错误:
But unfortunately I always get errors like as:
Error using svmtrain (line 335)
Y must contain exactly two groups for method 'SMO'.
这就是我需要你帮助的原因。
That is why I need your help please.
任何帮助都将非常感谢!
Any help will be very appreciated!
推荐答案
您是否尝试使用两个类来实施分类培训?你的标签= [ones(size(C2res {1},2),1)];
只包含一个值,似乎预计有两个值(两个类别) )。我认为这就是出错的原因。
Are you trying to implement the classification training with two classes? Your label = [ones(size(C2res{1},2),1)];
contains only one value, and it seems to be expected two values (as two categories). I think that's the reason the error comes out.
如果您要应用单类SVM,请尝试添加此类选项(请参阅此页有关该选项的更多参考资料):
If you are applying one-class SVM, try to add such option (see this page for more references on the option):
SVMStruct = svmtrain(XTrain , label,'-t 0 -s 2');
这篇关于使用SVM训练我的数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!