How to solve the SVMTRAIN 's groups error?

1 回表示 (過去 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 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by