我正在尝试从一个 300*299
的训练矩阵中学习相关特征,通过将其中的一行作为测试数据,并在其上应用 sequentialfs
。我使用了以下代码:
>> 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
大小的数组。Predict将为我提供对于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 列吗? - Ander Biguri