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 50 51
| fich=fopen(filelarg,'r');
while feof(fich)==0,
w=fscanf(fich,'%f');
end
fclose(fich);
t=length(w);
fc=fopen('datal.txt','w');
for i=1:t,
dt=(w(i)/w(1));
dts=num2str(dt);
fprintf(fc,'%s\t',dts);
end
fclose(fc);
file='larg_apprentissage1.txt';
fich1=fopen(file,'r');
while feof(fich1)==0,
w1=fscanf(fich1,'%f');
end
fclose(fich1);
t=length(w1);
for i=1:t,
donn(i,1)=i;
donn(i)=(w1(i)/w1(1));
if(donn(i)>0.85)
clas(i)=0;
else
clas(i)=1;
end
end
fcc=fopen('datal.txt','r');
while feof(fcc)==0
data=fscanf(fcc,'%f');
end
svmstruct=svmtrain(donn,clas,'kernel_function','linear');
for i=1:length(data),
group(i)=svmclassify(svmstruct,data(i));
ima(i)=i;
end
plot(ima,group,'--rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',10);
p = plot(ima(1),group(1),'--rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',10);
xlim([min(ima) max(ima)]);
ylim([min(group) max(group)]);
title('classification','Color',[0 1 1]);
xlabel('Images','Color',[0 1 1]);
ylabel('baillement ou non baillement','Color',[0 1 1]);
for n = 2:numel(ima)
set(p,'xdata',ima(1:n),'ydata',group(1:n));
drawnow;
pause(0.1);
end |
Partager