bug in fitcecoc() help --> predict function error

entering in order, the command:
[~,~,~,PosteriorRegion] = predict(Mdl,[x1Grid(:),x2Grid(:)]);
generates an error:
>> main2a1
Error using classreg.learning.impl.CompactSVMImpl/score (line 62)
You must pass X as a matrix with 4 columns.
Error in classreg.learning.classif.CompactClassificationSVM/score (line 424)
f = score(this.Impl,X,true,varargin{:});
Error in classreg.learning.classif.ClassificationModel/predict (line 410)
scores = score(this,X,varargin{:});
Error in classreg.learning.classif.CompactClassificationSVM/predict (line 266)
predict@classreg.learning.classif.ClassificationModel(this,X,varargin{:});
Error in classreg.learning.classif.CompactClassificationECOC>localScore/loopBody (line 922)
[~,s] = predict(trained{l},X,predictArgs{:});
Error in internal.stats.parallel.smartForSliceout (line 174)
[slice{:}] = loopbody(iter, S);
Error in classreg.learning.classif.CompactClassificationECOC>localScore (line 886)
internal.stats.parallel.smartForSliceout(T,@loopBody,useParallel);
Error in classreg.learning.classif.CompactClassificationECOC/score (line 184)
pscore = localScore(X,trained,useParallel,verbose,this.ObservationsInRows);
Error in classreg.learning.classif.CompactClassificationECOC/predict (line 366)
[negloss,pscore] = score(...
Error in main2a1 (line 6)
[~,~,~,PosteriorRegion] = predict(Mdl,[x1Grid(:),x2Grid(:)]);
>>

4 件のコメント

Yuzhen Lu
Yuzhen Lu 2018 年 10 月 23 日
編集済み: Yuzhen Lu 2018 年 10 月 23 日
Try the code (for model training to generate Mdl):
X = meas(:,3:4);
Walter Roberson
Walter Roberson 2018 年 10 月 23 日
The model has been built with 4 measurements per sample, but the prediction is trying to be done with only 2 measurements per sample.
Ravi Singh
Ravi Singh 2020 年 3 月 24 日
Hi Walter ,
I need to know if i can generate one svm model(mdl.mat) file and use it for different data several times. I had generated one file and tried using it with different data having same feature but i got error stating it does not have same number of columns.
Walter Roberson
Walter Roberson 2020 年 3 月 25 日
The number of columns of data processed through predict() must be the same as the number of columns of data trained on.
If the different data has matching columns plus extra columns, then extract the corresponding columns to pass to predict()

サインインしてコメントする。

回答 (1 件)

Nicolas Schmit
Nicolas Schmit 2017 年 9 月 20 日

0 投票

main2a1 Error using classreg.learning.impl.CompactSVMImpl/score (line 62) You must pass X as a matrix with 4 columns.
-> Check the number of columns of the matrix X when using predict(Mdl, X);

カテゴリ

質問済み:

2017 年 8 月 2 日

コメント済み:

2020 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by