Implementing sequentialfs
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Ilya
il 16 Feb 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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!