How to solve the SVMTRAIN 's groups error?

1 vue (au cours des 30 derniers jours)
phdcomputer Eng
phdcomputer Eng le 3 Mar 2020
Commenté : phdcomputer Eng le 11 Mar 2020
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 commentaires
Image Analyst
Image Analyst le 9 Mar 2020
Supply just two groups (columns).
phdcomputer Eng
phdcomputer Eng le 11 Mar 2020
@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?

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by