4
我試圖從300*299
培訓矩陣中學習相關的功能,將它作爲我的測試數據並應用sequentialfs
。我用下面的代碼:Matlab功能選擇
>> Md1=fitcdiscr(xtrain,ytrain);
>> func = @(xtrain, ytrain, xtest, ytest) sum(ytest ~= predict(Md1,xtest));
>> learnt = sequentialfs(func,xtrain,ytrain)
xtrain
和ytrain
分別299*299
和299*1
。預測會給我預測的標籤xtest
(這是從原始xtrain一些隨機行)。
然而,當我跑我的代碼,我得到以下錯誤:
Error using crossval>evalFun (line 480)
The function '@(xtrain,ytrain,xtest,ytest)sum(ytest~=predict(Md1,xtest))' generated the following error:
X must have 299 columns.
Error in crossval>getFuncVal (line 497)
funResult = evalFun(funorStr,arg(:));
Error in crossval (line 343)
funResult = getFuncVal(1, nData, cvp, data, funorStr, []);
Error in sequentialfs>callfun (line 485)
funResult = crossval(fun,x,other_data{:},...
Error in sequentialfs (line 353)
crit(k) = callfun(fun,x,other_data,cv,mcreps,ParOptions);
Error in new (line 13)
learnt = sequentialfs(func,xtrain,ytrain)
哪兒我去錯了嗎?
不'xtest'有299列? –
是的。它是一個1 * 299的行向量。 – Apurv
我建議你加一個[mcve],否則我們不能測試它 –