📄 da_gpev.m
字号:
%
% da_gpev.m
%
% Evaluates the performance of the GP after the algorithm has finished
%
da_front;
drawnow
set(w1,'NumberTitle','off','Name','Analysing Performance of GP models');
text(1)=da_text(w1,230,300,150,15,'Working. Please wait...',[1 1 1],[0 0 0]);
drawnow;
[gen_reached L]=size(run_pop);
%
% Find the minimum validation error
%
min_er=1e100;
best=0;
for i=1:gen_reached
mem=strrep(run_pop(i,:),'/','./');
mem=strrep(mem,'*','.*');
mem=strrep(mem,'^','.^');
for i=1:num_inp;
eval(['u' num2str(i) '= u(:,' num2str(i) ');']);
end;
ty=eval(mem);
for i=1:num_inp;
eval(['u' num2str(i) '= uv(:,' num2str(i) ');']);
end;
vy_p=eval(mem);
if ffunc=='ccf';
dta=[ty ones(num_data,1)];
[num_datav L]=size(vy);
dta2=[vy_p ones(num_datav,1)];
theta=inv(dta'*dta)*dta'*y;
ty=dta*theta;
vy_p=dta2*theta;
end;
if rms(vy,vy_p)<=min_er;
min_er=rms(vy,vy_p);
best=i;
end
end
set(text(1),'visible','off');
% Plot a couple of axes
ax1=axes(...
'Units','pixels',...
'Position',[345 265 250 125],...
'Box','on',...
'Color',[0 0 0],...
'fontsize',10,...
'Visible','on');
ax2=axes(...
'Units','pixels',...
'Position',[345 65 250 125],...
'Box','on',...
'Color',[0 0 0],...
'fontsize',10,...
'Visible','on');
box1=uicontrol(w1,...
'style','frame',...
'position',[5 220 300 195],...
'foregroundColor',[1 1 1],...
'backgroundcolor',[0 0 0.5]);
drawnow;
box2=uicontrol(w1,...
'style','frame',...
'position',[5 80 300 100],...
'foregroundColor',[1 1 1],...
'backgroundcolor',[0 0 0.5]);
drawnow;
text(1)=da_text2(w1,5,5,610,20,'',[1 1 1],[0 0.5 0],'left');
text(2)=da_text2(w1,5,35,150,20,'Currently viewing model:',[1 1 1],[0 0 0.5],'left');
text(3)=da_text2(w1,170,35,50,20,'',[1 1 1],[0 0 0.5],'center');
text(4)=da_text(w1,345,400,100,20,'Training set:',[1 1 1],[0 0 0]);
text(5)=da_text(w1,345,200,100,20,'Testing set:',[1 1 1],[0 0 0]);
text(6)=da_text2(w1,10,390,290,20,'Model Statistics',[1 1 1],[0 0 1],'center');
text(7)=da_text(w1,10,350,150,20,'Training RMS error:',[1 1 1],[0 0 0.5]);
text(8)=da_text2(w1,180,350,120,20,'',[1 1 1],[0 0.5 0],'center');
text(9)=da_text(w1,10,320,150,20,'STD(training error):',[1 1 1],[0 0 0.5]);
text(10)=da_text2(w1,180,320,120,20,'',[1 1 1],[0 0.5 0],'center');
text(11)=da_text(w1,10,270,150,20,'Testing RMS error:',[1 1 1],[0 0 0.5]);
text(12)=da_text2(w1,180,270,120,20,'',[1 1 1],[0 0.5 0],'center');
text(13)=da_text(w1,10,240,150,20,'STD(testing error):',[1 1 1],[0 0 0.5]);
text(14)=da_text2(w1,180,240,120,20,'',[1 1 1],[0 0.5 0],'center');
text(15)=da_text(w1,10,100,75,20,'Model:',[1 1 1],[0 0 0.5]);
text(16)=da_text(w1,260,100,30,20,num2str(gen_reached),[1 1 1],[0 0 0.5]);
text(17)=da_text(w1,220,120,50,20,'',[1 1 1],[0 0 0.5]);
text(18)=da_text(w1,110,100,10,20,'1',[1 1 1],[0 0 0.5]);
text(19)=da_text2(w1,10,155,290,20,'Select Model',[1 1 1],[0 0 1],'center');
%
% Slider
%
old_sl1_value=1;
pl=best;
set(text(17),'string',num2str(old_sl1_value));
set(text(3),'string',num2str(pl));
set(text(1),'string',run_pop(pl,:));
sl1=uicontrol(w1,...
'style','slider',...
'position',[120 100 130 20],...
'max',gen_reached,...
'min',1,...
'value',pl,...
'callback',[
'pl=ceil(get(sl1,''value''));',...
'if pl ~= old_sl1_value;',...
'set(text(17),''string'',num2str(pl));',...
'set(text(1),''string'',run_pop(pl,:));',...
'set(text(3),''string'',num2str(pl));',...
'old_sl1_value=pl;',...
'mem=strrep(run_pop(pl,:),''/'',''./'');',...
'mem=strrep(mem,''*'',''.*'');',...
'mem=strrep(mem,''^'',''.^'');',...
'for i=1:num_inp;',...
'eval([''u'' num2str(i) ''= u(:,'' num2str(i) '');'']);',...
'end;',...
'ty=eval(mem);',...
'for i=1:num_inp;',...
'eval([''u'' num2str(i) ''= uv(:,'' num2str(i) '');'']);',...
'end;',...
'vy_p=eval(mem);',...
'if ffunc==''ccf'';',...
'dta=[ty ones(num_data,1)];',...
'[num_datav L]=size(vy);',...
'dta2=[vy_p ones(num_datav,1)];',...
'theta=inv(dta''*dta)*dta''*y;',...
'ty=dta*theta;',...
'vy_p=dta2*theta;',...
'end;',...
'axes(ax1);',...
'cla;',...
'plot(ty,''r'');',...
'hold on;',...
'plot(y,''g'');',...
'set(text(8),''string'',num2str(rms(y,ty)));',...
'set(text(10),''string'',num2str(std(y-ty)));',...
'axes(ax2);',...
'cla;',...
'plot(vy_p,''r'');',...
'hold on;',...
'plot(vy,''g'');',...
'set(text(12),''string'',num2str(rms(vy,vy_p)));',...
'set(text(14),''string'',num2str(std(vy-vy_p)));',...
'drawnow;',...
'end']);
%
% Simplify button
%
but1=uicontrol(w1,'style','push','position',[235 35 70 20],'string','Simplify','callback',[
'set(text(1),''string'',n_simp2(run_pop(pl,:)))']);
%
% Set everything to the best model
%
%
% Find the minimum validation error
%
mem=strrep(run_pop(best,:),'/','./');
mem=strrep(mem,'*','.*');
mem=strrep(mem,'^','.^');
for i=1:num_inp;
eval(['u' num2str(i) '= u(:,' num2str(i) ');']);
end;
ty=eval(mem);
for i=1:num_inp;
eval(['u' num2str(i) '= uv(:,' num2str(i) ');']);
end;
vy_p=eval(mem);
if ffunc=='ccf';
dta=[ty ones(num_data,1)];
[num_datav L]=size(vy);
dta2=[vy_p ones(num_datav,1)];
theta=inv(dta'*dta)*dta'*y;
ty=dta*theta;
vy_p=dta2*theta;
end;
axes(ax1);
cla;
plot(ty,'r');
hold on;
plot(y,'g');
set(text(8),'string',num2str(rms(y,ty)));
set(text(10),'string',num2str(std(y-ty)));
axes(ax2);
cla;
plot(vy_p,'r');
hold on;
plot(vy,'g');
set(text(12),'string',num2str(rms(vy,vy_p)));
set(text(14),'string',num2str(std(vy-vy_p)));
set(text(17),'string',num2str(best));
drawnow;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -