我想實現的特徵選擇sequentialfs。我看到這個帖子:Sequential feature selection Matlab實施Sequentialfs
試圖按照給出實施解決方案的例子。
我TrainVec是尺寸268 x1475的矩陣而TestVec是116x1475和TestLabel是116 X 1和TestLabel是268×1.
我實現的代碼是
f = @(TrainVec,TrainLabel,TestVec,TestLabel) sum(TestLabel ~= predict_label);
fs = sequentialfs(f,Vec,Label);
錯誤我得到是:
??? 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{:},...
我檢查了我所有的矩陣,並確保它們是相同的尺寸。不知道什麼是錯的。需要一些指導。 錯誤在357 爆擊(K)= callfun(樂趣,X,other_data,CV,mcreps)==> sequentialfs;
仍然沒有能夠做到這一點......順便說一句,我使用的模型預測LIBSVM。無論如何影響? – lakesh 2012-02-05 11:17:03
我有雙重檢查。 TestLabel和predict_label具有相同的尺寸...但錯誤仍然存在... – lakesh 2012-02-09 18:03:21
我的TrainLabel值是-1和1 ..應該是0還是1?這有什麼不同嗎? – lakesh 2012-02-09 18:48:10