Can anyone plz help regarding svmtrain in matlab?

I get these errors when I use svmtrain() in matlab.What to do?
Error using | Matrix dimensions must agree.
Error in svmtrain (line 265) nans = any(isnan(training)|isnan(groupIndex),2);

3 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 3 日
Post your code
Sheema Khattak
Sheema Khattak 2014 年 8 月 4 日
features=[1659,1486;1635,1534;1509,1228;113,676;712,1780;778,34;2409,946;502,1600;1137,1456;1845,934;22,520;1953,982;1617,910;1587,796;1767,676;2205,772;1287,802;2715,550;1863,586;1239,526;2055,778;2271,556;1863,886;2601,370;];
testset=[1269,988;802,1456;945,820;2619,814;2565,724;421,780;844,1768;430,1372;1863,1900;592,52;1617,1762;2391,82;2169,1576;850,472;1587,706;1437,976;1509,1556;1309,2284;1785,868;1869,856;2169,1186;1761,994;1725,862;1833,790;1833,538;];
labels=[ones(24,1),-ones(24,1)]
svmstruct=svmtrain(features,labels);
Andrew Reibold
Andrew Reibold 2014 年 8 月 5 日
This is very petty and you can ignore it, but most of the community would appreciate the extra half second to type out 'please' haha. Good luck!

回答 (1 件)

Shaarif Zia
Shaarif Zia 2014 年 8 月 5 日

0 投票

A grouping variable must have the same number of observations (rows) as the table, data set array, or numeric array you are grouping. (Read here )
Assuming you have 24 data points in 2D space (i.e. with two features each) and 24 labels of which 12 are 1's and 12 are -1's.
labels = [ones(12,1);-ones(12,1)];
Hope this helps.

この質問は閉じられています。

質問済み:

2014 年 8 月 3 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by