function netw(datafile,mappfile,curv,link);
% The function:
%
% netw(datafile,mappfile,curv,link);
%
% draws the results stored in files created by NLPm.exe.
% The two first args give the name of the files where
% the results are stored:
% datafile.dat = learning or validation set
% datafile.prj = projection of datafile.dat
% datafile.jrp = reconstruction of datafile.dat
% mappfile.pro = prototypes after quantization
% mappfile.crv = links between prototypes
% mappfile.map = mapped prototypes
% mappfile.lnk = links between mapped prototypes
%
% The optional flags <curv> and <link> are used either to
% show or to hide the links between (mapped) prototypes.
% Default value are respectively 1 and 0
if nargin<2,
disp('you must specify two files !');
return;
end;
if isempty(datafile), data = 0; else, data = 1; end;
if isempty(mappfile), mapp = 0; else, mapp = 1; end;
if nargin<3, curv = 1; end;
if nargin<4, link = 0; end;
% OUVERTURE DES FICHIERS
if data>0,
[dat,ndat,ddat] = ld(strcat(datafile,'.dat'));
if ndat*ddat==0, okdat=0; else, okdat=1; end;
[prj,nprj,dprj] = ld(strcat(datafile,'.prj'));
if nprj*dprj==0, okprj=0; else, okprj=1; end;
[jrp,njrp,djrp] = ld(strcat(datafile,'.jrp'));
if njrp*djrp==0, okjrp=0; else, okjrp=1; end;
% restriction
if ndat>20000, naff=20000; else, naff=ndat; end;
else,
okdat = 0;
okprj = 0;
okjrp = 0;
end;
if mapp>0,
[pro,npro,dpro] = ld(strcat(mappfile,'.pro'));
if npro*dpro==0, okpro=0; else, okpro=1; end;
if curv>0,
[crv,ncrv,temp] = ld(strcat(mappfile,'.crv'));
if ncrv*temp==0, okcrv=0; else, okcrv=1; end;
else,
okcrv = 0;
end;
[map,nmap,dmap] = ld(strcat(mappfile,'.map'));
if nmap*dmap==0, okmap=0; else, okmap=1; end;
if link>0,
[lnk,nlnk,temp] = ld(strcat(mappfile,'.lnk'));
if nlnk*temp==0, oklnk=0; else, oklnk=1; end;
else,
oklnk = 0;
end;
else,
okpro = 0;
okcrv = 0;
okmap = 0;
oklnk = 0;
end;
% AFFICHAGE
figure;
% donnees initiales
subplot(2,2,1);
if okdat>0,
if ddat==1,
plot(dat(1:naff,1),dat(1:naff,1),'r.');
elseif ddat==2,
plot(dat(1:naff,1),dat(1:naff,2),'r.');
else,
plot3(dat(1:naff,1),dat(1:naff,2),dat(1:naff,3),'r.');
end;
end;
if okpro>0,
hold on;
if okcrv>0,
for k=1:ncrv,
i = 1 + crv(k,1);
j = 1 + crv(k,2);
if dpro==1,
plot([pro(i,1);pro(i,1);pro(j,1);pro(j,1);pro(i,1)],[pro(i,1);pro(j,1);pro(j,1);pro(i,1);pro(i,1)],'b-');
elseif dpro==2,
plot([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],'b-');
else,
plot3([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],[pro(i,3);pro(j,3)],'b-');
end;
end;
end;
if dpro==1,
plot(pro(:,1),pro(:,1),'b.');
elseif dpro==2,
plot(pro(:,1),pro(:,2),'bo');
else,
plot3(pro(:,1),pro(:,2),pro(:,3),'bo');
end;
end;
axis equal;
title('Initial Data & Network');
% controle
if okprj>0 & okjrp>0,
if nprj ~= njrp,
disp('#rows not equal for prj and jrp');
return;
end;
end;
% donnees deprojetees
subplot(2,2,2);
if okjrp>0,
if djrp==1,
plot(jrp(1:naff,1),jrp(1:naff,1),'r.');
elseif djrp==2,
plot(jrp(1:naff,1),jrp(1:naff,2),'r.');
else,
plot3(jrp(1:naff,1),jrp(1:naff,2),jrp(1:naff,3),'r.');
end;
end;
if okpro>0,
hold on;
if oklnk>0,
for k=1:nlnk,
i = 1 + lnk(k,1);
j = 1 + lnk(k,2);
if dpro==1,
plot([pro(i,1);pro(i,1);pro(j,1);pro(j,1);pro(i,1)],[pro(i,1);pro(j,1);pro(j,1);pro(i,1);pro(i,1)],'g-');
elseif dpro==2,
plot([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],'g-');
else,
plot3([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],[pro(i,3);pro(j,3)],'g-');
end;
end;
end;
if okcrv>0,
for k=1:ncrv,
i = 1 + crv(k,1);
j = 1 + crv(k,2);
if dpro==1,
plot([pro(i,1);pro(i,1);pro(j,1);pro(j,1);pro(i,1)],[pro(i,1);pro(j,1);pro(j,1);pro(i,1);pro(i,1)],'b-');
elseif dpro==2,
plot([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],'b-');
else,
plot3([pro(i,1);pro(j,1)],[pro(i,2);pro(j,2)],[pro(i,3);pro(j,3)],'b-');
end;
end;
end;
if dpro==1,
plot(pro(:,1),pro(:,1),'b.');
elseif dpro==2,
plot(pro(:,1),pro(:,2),'bo');
else,
plot3(pro(:,1),pro(:,2),pro(:,3),'bo');
end;
end;
axis equal;
title('Deprojected Data & Network');
% controle
if okpro>0 & okmap>0,
if npro ~= nmap,
disp('#rows not equal for pro and map');
return;
end;
end;
% donnees projetees
subplot(2,2,3);
if okprj>0,
if dprj==1,
plot(prj(1:naff,1),prj(1:naff,1),'r.');
elseif dprj==2,
plot(prj(1:naff,1),prj(1:naff,2),'r.');
else,
plot3(prj(1:naff,1),prj(1:naff,2),prj(1:naff,3),'r.');
end;
end;
if okmap>0,
hold on;
if oklnk>0,
for k=1:nlnk,
i = 1 + lnk(k,1);
j = 1 + lnk(k,2);
if dmap==1,
plot([map(i,1);map(i,1);map(j,1);map(j,1);map(i,1)],[map(i,1);map(j,1);map(j,1);map(i,1);map(i,1)],'g-');
elseif dmap==2,
plot([map(i,1);map(j,1)],[map(i,2);map(j,2)],'g-');
else,
plot3([map(i,1);map(j,1)],[map(i,2);map(j,2)],[map(i,3);map(j,3)],'g-');
end;
hold on;
end;
end;
if okcrv>0,
for k=1:ncrv,
i = 1 + crv(k,1);
j = 1 + crv(k,2);
if dmap==1,
plot([map(i,1);map(i,1);map(j,1);map(j,1);map(i,1)],[map(i,1);map(j,1);map(j,1);map(i,1);map(i,1)],'b-');
elseif dmap==2,
plot([map(i,1);map(j,1)],[map(i,2);map(j,2)],'b-');
else,
plot3([map(i,1);map(j,1)],[map(i,2);map(j,2)],[map(i,3);map(j,3)],'b-');
end;
hold on;
end;
end;
if dmap==1,
plot(map(:,1),map(:,1),'b.');
elseif dmap==2,
plot(map(:,1),map(:,2),'bo');
else,
plot3(map(:,1),map(:,2),map(:,3),'bo');
end;
end;
axis equal;
title('Projected Data & Network');
% erreur de proj/deproj
subplot(2,2,4);
if okdat>0 & okjrp>0,
erp = jrp - dat;
if djrp==1,