⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 da_lsqs.m

📁 遗传算法的源程序
💻 M
字号:
%
% da_lsqs
%
% Least squares regression entry point
%

%
% Clear the screen
%
da_front;
drawnow;

%
% Make sure that none of the variables have a zero
% standard deviation
%
s=std(data);
[D L]=size(s);
for i = 1 : L
	if s(i)==0
		include_var(i)=0;
		output_var(i)=0;
	end
end

%
% Draw a set of axes
%
set(w1,'NumberTitle','off','Name','Multiple Linear Regression (MLR)');
figure(w1);
ax1=axes(...
	'Units','pixels',...
	'Position',[60 230 200 180],...
	'Box','on',...
	'Color',[0 0 0],...
	'Visible','on');
Xlabel('Sample number');
Ylabel('Output');

text2=uicontrol(w1,...
	'Style','text',...
	'Position',[50 415 150 15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Regression results:');

text1=uicontrol(w1,...
	'Style','text',...
	'Position',[50 160 100 15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Contributions:');

ax2=axes(...
	'Units','pixels',...
	'Position',[60 80 200 75],...
	'Box','on',...
	'Color',[0 0 0],...
	'Visible','on');
Xlabel('Variable number');
Ylabel('Contibution');



%
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%
% Now have three mutually exclusive radio buttons for
% optimum regression options
%
[Dlen Dent]=size(data);

pcr_rad1=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 300 140 20],...
	'String','Include polynomials',...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'CallBack','set(pcr_rad3,''Value'',0)');

pcr_rad3=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 270 300 20],...
	'String','Use best combination (max 10 variables)',...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'CallBack','set(pcr_rad1,''Value'',0)');



%
% Print title for these options
%
text1=uicontrol(w1,...
	'Style','text',...
	'Position',[350 330 150 15],...
	'BackGroundColor',[1 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Regression options...');

%
% Slider for include polynomials option 
%
sl1=uicontrol(w1,...
	'Style','slider',...
	'Position',[420 300 100 20],...
	'Min',0,...
	'Max',10,...
	'Value',2,...
	'BackgroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'CallBack','set(sl1_current,''String'',[num2str(ceil(get(sl1,''Value''))) '' powers''])');
sl1_current=uicontrol(w1,...
		'Style','text',...
		'Position',[530 300 70 15],...
		'BackGroundColor',[1 0 0],...
		'ForegroundColor',[1 1 1],...
		'String',[num2str(ceil(get(sl1,'Value'))) ' powers']);

%
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

%
% CALCULATE button
%
pca_but1=uicontrol(w1,...
	'Style','push',...
	'Position',[260 10 100 20],...
	'String','CALCULATE',...
	'CallBack',[...
		'da_lsgo;',...
		'axes(ax1);',...
		'plot([vy py]);',...
		'[D L]=size(py);',...
		'set(ax1,''Xlim'',[0 D]);',...
		'Xlabel(''Sample number'');',...
		'Ylabel(''Output'');',...
		'axes(ax2);',...
		'bar(impact);',...
		'[D L]=size(impact);',...
		'set(ax2,''Xlim'',[0 D]);',...
		'Xlabel(''Variable number'');',...
		'Ylabel(''Contribution'');']);


%
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%
% Options for data splitting
%

text2=uicontrol(w1,...
	'Style','text',...
	'Position',[320 220 200 15],...
	'BackGroundColor',[1 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Training/Validation splits...');

%
% Percentage straight split
%
pcr_rad4=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 190 150 20],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Percentage partition',...
	'CallBack',[
		'set(pcr_rad4,''Value'',1);',...
		'set(pcr_rad5,''Value'',0);',...
		'set(pcr_rad6,''Value'',0);',...
		'set(pcr_rad7,''Value'',0);']);


%
% Slider for this:
%
	pcr_rad4sl=uicontrol(w1,...
		'Style','slider',...
		'Position',[420 190 100 20],...
		'Min',0,...
		'Max',100,...
		'Value',50,...
		'BackgroundColor',[0 0 0],...
		'ForeGroundColor',[1 1 1],...
		'String','Percentage',...
		'CallBack','set(pcr_rad4sl_current,''String'',[num2str(ceil(get(pcr_rad4sl,''Value''))) '' % train''])');
	pcr_rad4sl_current=uicontrol(w1,...
		'Style','text',...
		'Position',[530 190 70 15],...
		'BackGroundColor',[1 0 0],...
		'ForegroundColor',[1 1 1],...
		'String',[num2str(ceil(get(pcr_rad4sl,'Value'))) ' % train']);

	
%
% Randomly assign percentage
%
pcr_rad5=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 160 150 20],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Randomly assign',...
	'CallBack',[
		'set(pcr_rad4,''Value'',0);',...
		'set(pcr_rad5,''Value'',1);',...
		'set(pcr_rad6,''Value'',0);',...
		'set(pcr_rad7,''Value'',0);']);

set(pcr_rad5,'enable','off');

%
% Slider for this
%
	pcr_rad5sl=uicontrol(w1,...
		'Style','slider',...
		'Position',[420 160 100 20],...
		'Min',0,...
		'Max',100,...
		'Value',50,...
		'BackgroundColor',[0 0 0],...
		'ForeGroundColor',[1 1 1],...
		'String','Percentage',...
		'CallBack','set(pcr_rad5sl_current,''String'',[num2str(ceil(get(pcr_rad5sl,''Value''))) '' % train''])');
	pcr_rad5sl_current=uicontrol(w1,...
		'Style','text',...
		'Position',[530 160 70 15],...
		'BackGroundColor',[1 0 0],...
		'ForegroundColor',[1 1 1],...
		'String',[num2str(ceil(get(pcr_rad5sl,'Value'))) ' % train']);


%
% Multiple block splitting
%
pcr_rad6=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 130 150 20],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Multiple block split',...
	'CallBack',[
		'set(pcr_rad4,''Value'',0);',...
		'set(pcr_rad5,''Value'',0);',...
		'set(pcr_rad6,''Value'',1);',...
		'set(pcr_rad7,''Value'',0);']);
%
% Slider for this
%
	pcr_rad6sl=uicontrol(w1,...
		'Style','slider',...
		'Position',[420 130 100 20],...
		'Min',3,...
		'Max',ceil(Dlen/8),...
		'Value',ceil(Dlen/16),...
		'BackgroundColor',[0 0 0],...
		'ForeGroundColor',[1 1 1],...
		'String','Percentage',...
		'CallBack','set(pcr_rad6sl_current,''String'',[num2str(ceil(get(pcr_rad6sl,''Value''))) '' blocks''])');
	pcr_rad6sl_current=uicontrol(w1,...
		'Style','text',...
		'Position',[530 130 70 15],...
		'BackGroundColor',[1 0 0],...
		'ForegroundColor',[1 1 1],...
		'String',[num2str(ceil(get(pcr_rad6sl,'Value'))) ' blocks']);





pcr_rad7=uicontrol(w1,...
	'Style','radio',...
	'Position',[270 100 200 20],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Split data alternately',...
	'CallBack',[
		'set(pcr_rad4,''Value'',0);',...
		'set(pcr_rad5,''Value'',0);',...
		'set(pcr_rad6,''Value'',0);',...
		'set(pcr_rad7,''Value'',1);']);

%
% Set so that the default is percentage split
%
set(pcr_rad4,'Value',1);
set(pcr_rad5,'Value',0);
set(pcr_rad6,'Value',0);
set(pcr_rad7,'Value',0);


%
% Do results box
%
drawnow;
box1=uicontrol(w1,...
	'Style','frame',...
	'Position',[269 359 302 49],...
	'BackGroundColor',[0 0 1]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -