Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
Stephen Dicke
Stephen Dicke am 2 Aug. 2017
Kommentiert: Walter Roberson am 25 Mär. 2020
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 Kommentare
Ravi Singh
Ravi Singh am 24 Mär. 2020
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 am 25 Mär. 2020
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()

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Nicolas Schmit
Nicolas Schmit am 20 Sep. 2017
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);

Community Treasure Hunt

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

Start Hunting!

Translated by