Implementing sequentialfs
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Ilya
2012 年 2 月 16 日
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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!