1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
tic;
load('toto.mat')
TS=0;
compt =1;
for c= 0.1:0.1 :100
for sigma=0.1:0.1 :150
SVMstruct=svmtrain(train_BA,train_BC,'kernel_function','rbf','method','smo','rbf_sigma',sigma,'boxconstraint',c);
class=svmclassify(SVMstruct,test_BA);
[nbligne,h]=size(test_BC);
resultas=class-test_BC;
nbs=0;
for i=1:1 :nbligne
if resultas(i)==0 nbs=nbs+1;
end
end
tauxs=nbs/nbligne
if tauxs>TS
TS=tauxs;
compt=compt+1;
mc=c;
msigma=sigma;
end
end
end
bestT=TS;
bestC=mc;
bestsigma=msigma;
nbiteration=compt;
toc
msigma= bestsigma;
mc = bestC;
nbi=nbiteration;
mTS=TS;
fid = fopen('smo-rbf.mat','at');
fprintf(fid,'%s','msigma =');
fprintf(fid,' %i\n',msigma);
fprintf(fid,'%s','mc =');
fprintf(fid,'%i\n',mc);
fprintf(fid,'%s','mTS =');
fprintf(fid,'%i\n',mTS);
fprintf(fid,'%s','nbi =');
fprintf(fid,' %i\n',nbi);
fprintf(fid,'%s','TE =');
fprintf(fid,'%f\n',toc);
fclose(fid) |
Partager