Matlab功能选择

时间:2016-11-12 06:19:43

标签: matlab machine-learning runtime-error feature-selection

我正在尝试从sequentialfs训练矩阵中学习相关要素,将其中的随机行作为我的测试数据并在其上应用>> Md1=fitcdiscr(xtrain,ytrain); >> func = @(xtrain, ytrain, xtest, ytest) sum(ytest ~= predict(Md1,xtest)); >> learnt = sequentialfs(func,xtrain,ytrain) 。我使用了以下代码:

xtrain

ytrain299*299分别为299*1xtest。预测将给出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) 的预测标签(这是原始xtrain中的一些随机行)。

但是,当我运行我的代码时,我收到以下错误:

var express = require('express');
var meter = require('./meter');  // meter will be an object you can use later on
var app = express();

app.get('/',meter.hi); // you actually don't need another annonimous function, can use hi directly as the callback

app.listen(3000);
console.log('listening on 3000 port')

我哪里出错了?

1 个答案:

答案 0 :(得分:1)

您应该在 func内构建分类器,而不是之前。 sequentialfs每次在不同的集合上调用该函数,并且必须仅为每个集合专门构建分类器,仅使用为该迭代选择的特征sequentialfs

我不确定自己是否清楚,实际上你应该将代码的第一行移到func

的正文中

来源:MathWorks