How to solve the SVMTRAIN 's groups error?

1 次查看(过去 30 天)
I am using SVM classifier for binary classification(class labels are 0 and 1) by using this code:
mysvm=svmtrain(xtrain,ytrain,'kernel_function','linear','boxconstraint',2);
sv=svmclassify(mysvm,xtest);
but Matlab shows this error
Error using svmtrain (line 275)
SVMTRAIN only supports classification into two groups. GROUP contains 50 groups.
I'll be very grateful to have your opinions how to solve this error.
Thanks
  2 个评论
phdcomputer Eng
phdcomputer Eng 2020-3-11
@Image Analyst Thanks
my classification code is:
rows=(1:n);
test_count=floor((0.2)*n);
[n,m]=size(data0);
test_rows=randsample(rows,test_count);
train_rows=setdiff(rows,test_rows);
test=data0(test_rows,:);
train=data0(train_rows,:);
xtest=test(:,1:m-1);
ytest=test(:,m);
xtrain=train(:,1:m-1);
ytrain=train(:,m);
output_svm= classificationa(xtest,xtrain,ytrain);
and then by comparing xtrain&ytrain with xtest, I obtain the resault of svm classifier.
In this code, n=62 and m=30 so test_count=12 , test is a 12x30 matrix and train is a 50x30 matrix
so in the error, 50 groups is because of train matrix:
Error using svmtrain (line 275)
SVMTRAIN only supports classification into two groups. GROUP contains 50 groups.
but I don't know how to solve this error as you said Supplying just two groups (columns). I'll be very grateful to have your opinion how to change the number of groups, should I change the the above classification codes?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by