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],否则我们不能测试它 –