3-fold cross validation for svm

2 ビュー (過去 30 日間)
Philip Gigliotti
Philip Gigliotti 2018 年 10 月 3 日
編集済み: Philip Gigliotti 2018 年 10 月 3 日
Hello, I'm trying to execute a rid search 3 fold cross validation for svm. I am using an svm classifier from this package:
and the svm classifiers from exclass1.m.
I am relying on matlab's crossval package, but am having trouble with the function component and calling the right arguments.
Here is my attempt:
%Gaussian
C = [.00000001, .0000001, .000001, .00001, .0001, .001, .01, .1, 1, 10, 100, 1000]
G = [.00000001, .0000001, .000001, .00001, .0001, .001, .01, .1, .3, .5, 1]
grid = zeros(numel(C), numel(G));
[Xapp,yapp,xtest,ytest]=datasets('gaussian',n,0,sigma);
X =[Xapp,yapp,xtest,ytest]
for c = 1:numel(C)
for g = 1:numel(G)
vals = crossval(fun(Xapp, xtest,yapp, C(c), G(g)), X, 'kfold', 3);
grid(c,s) = mean(vals);
end
end
[cbest, sbest] = find(grid == max(grid(:)));
C_final = C(cbest);
S_final = S(sbest);
function svm = fun(Xapp, xtest, yapp, C, G)
[xsup,w,w0,pos,tps,alpha] = svmclass(Xapp,yapp,C,G,'Gaussian',1,1);
ypred = svmval(xtest,xsup,w,w0,'Gaussian',1,[ones(length(xtest),1)]);
end
The error I get is here:
Output argument "svm" (and maybe others) not assigned during call to "Problem_Set_2>fun".
Error in Problem_Set_2 (line 14) vals = crossval(fun(Xapp, xtest,yapp, C(c), G(g)), X, 'kfold', 3);
Any suggestions?

回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by