【发布时间】:2016-11-16 19:00:27
【问题描述】:
我正在尝试通过从中获取随机行作为我的测试数据并在其上应用 sequentialfs 来学习 300*299 训练矩阵中的相关特征。我使用了以下代码:
>> 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 列吗? -
是的。它是一个 1*299 行向量。
-
我建议你加一个minimal reproducible example,否则我们无法测试它
标签: matlab machine-learning runtime-error feature-selection