parameter optimization of support vector machine
Afficher commentaires plus anciens
hi i am new in matlab , i am using support vector machine for parameter optimizing purpose.I using the sample code which is given below-
grnpop = mvnrnd([1,0],eye(2),10);
>> redpop = mvnrnd([0,1],eye(2),10);
>> redpts = zeros(100,2);grnpts = redpts;
>> for i = 1:100
grnpts(i,:) = mvnrnd(grnpop(randi(10),:),eye(2)*0.2);
redpts(i,:) = mvnrnd(redpop(randi(10),:),eye(2)*0.2);
end;
>> k=10;
>> cdata = [grnpts;redpts];
grp = ones(200,1);
% green label 1, red label -1
grp(101:200) = -1;
>> cdata = [grnpts;redpts];
grp = ones(200,1);
% green label 1, red label -1
grp(101:200) = -1;
>> cvFolds = crossvalind('Kfold', grp, 10);
>> z=[3 5];
>> testIdx = (cvFolds == 1);
>> trainIdx = ~testIdx;
>> xtrain=cdata(trainIdx,:);
>> xtest=cdata(testIdx,:);
>> ytrain=grp(trainIdx);
>> svmStruct = svmtrain(xtrain,ytrain,'Kernel_Function','rbf',...
'rbf_sigma',z(1),'boxconstraint',z(2));
>> yfit = svmclassify(svmStruct,xtest);
>> minfn = @(z)crossval('mcr',cdata,grp,'Predfun',yfit,.....
@(xtrain,ytrain,xtest)crossfun(xtrain,ytrain,...
xtest,exp(z(1)),exp(z(2))));
>> opts = optimset('TolX',5e-4,'TolFun',5e-4);
>> [searchmin fval] = fminsearch(minfn,randn(2,1),opts)
but i found the following error-
Error using crossval (line 204)
Wrong number of arguments.
Error in
@(z)crossval('mcr',cdata,grp,'Predfun',yfit,@(xtrain,ytrain,xtest)crossfun(xtrain,ytrain,xtest,exp(z(1)),exp(z(2))))
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:});
please any one tell me why this error is comeing ,and also suggest the code.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Classification Trees dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!