필터 지우기
필터 지우기

How to solve the SVMTRAIN 's groups error?

조회 수: 2 (최근 30일)
phdcomputer Eng
phdcomputer Eng 2020년 3월 3일
댓글: phdcomputer Eng 2020년 3월 11일
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
Image Analyst
Image Analyst 2020년 3월 9일
Supply just two groups (columns).
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by