Implementing sequentialfs

1 次查看(过去 30 天)
C N N
C N N 2012-2-16
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
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 CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by