' The length of GROUP must equal the number of rows in TRAINING.',how can i solve this issue...?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi, I am new to the matlab coding.when iam using linear classifier to classify the test and train signal it shows' The length of GROUP must equal the number of rows in TRAINING.',and the code i have used is given below,
a=ones([1060,1]);
b=zeros([1060,1]);
c=cat(1,a,b);
class=classify(test,train,c,'linear');
SVMStruct=svmtrain(train,c);
class=svmclassify(SVMStruct,test,'Showplot',true);
class = knnclassify(test,train,c,1);
and
>>size(test)
ans =
2 6354
size(train)
ans =
2 9540
>> size(c)
ans =
2120 1
how can i solve this problem...?
Any response would be greatly appreciated. Thanks in advance.
댓글 수: 0
채택된 답변
the cyclist
2016년 11월 20일
I suggest you carefully read the documentation for classify, and really try to understand what each input represents.
The main conceptual thing to understand is that the third argument, group (your variable c), should have the same number of rows as the second argument, training, (your variable train). The reason is that you are telling classify which group that each row of training belongs to. For example,
training = [1 2;
6 5;
4 4;
1 1];
group = [1;
2;
2;
1];
would be telling MATLAB that the first and last row of training are in group 1, and the other two rows are in group 2.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!