Implementing sequentialfs

1 vue (au cours des 30 derniers jours)
C N N
C N N le 16 Fév 2012
I am trying to implement sequentialfs for feature selection. I saw this post : Sequential feature selection Matlab
Tried to follow the example given as the solution to implement.
My TrainVec is a matrix of dimension 268 x1475 whereas TestVec is 116x1475 and TestLabel is 116 x 1 and TestLabel is 268 x 1.
the code i implemented is
f = @(TrainVec,TrainLabel,TestVec,TestLabel) sum(TestLabel ~= predict_label); fs = sequentialfs(f,Vec,Label);
The error i get is :
??? Error using ==> crossval>evalFun at 505 The function '@(TrainVec,TrainLabel,TestVec,TestLabel)sum(TestLabel~=predict_label)' generated the following error: Matrix dimensions must agree. Error in ==> crossval>getFuncVal at 524 funResult = evalFun(funorStr,arg(:)); Error in ==> crossval at 363 funResult = getFuncVal(1, nData, cvp, data, funorStr, []); Error in ==> sequentialfs>callfun at 495 funResult = crossval(fun,x,other_data{:},...
I have checked all my matrixes and ensured that they are of same dimensions. Not sure what is wrong. Need some guidance. Error in ==> sequentialfs at 357 crit(k) = callfun(fun,x,other_data,cv,mcreps);
  1 commentaire
Ilya
Ilya le 16 Fév 2012
Your post does not show how you compute predict_label, nor does it say what Vec and Label are. It's hard to say without knowing that, but my guess would be that TestLabel and predict_label passed to f have different lengths.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by