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

📄 modlgui.m

📁 偏最小二乘算法在MATLAB中的实现
💻 M
📖 第 1 页 / 共 2 页
字号:
function modl = modlgui(x,y,out,action);
%MODLGUI Graphical user interface develops PCR, PLS and RR models.
% This function can be used to develop PCR, PLS and ridge
% regression models with a variety of scaling and cross-
% validation options. The function allows different model
% building options. Inputs are the matrix of predictor
% variables (x) and predicted variables (y).
% Input variable (out) is a TEXT variable that gives the name of
% the output variable that will contain the regression model
% in compact form. The output variable includes information about
% how the model was developed, scaling parameters, the final
% regression vector, and a date and time stamp (modl can be read
% using the function MODLRDER). MODLGUI also plots actual vs.
% fitted values and leverage vs. studentized residuals for
% outlier detection.
% I/O format:  modlgui(x,y,out);
% for example: modlgui(xdata,ydata,'model');
%
% See also MODLMKER, MODLPRED, MODLRDER and MODLDEMO

% Copyright
% Eigenvector Technologies
% 1995
global handl modl
if nargin<4&nargin>1,
  action  = 'initiate';
end
if strcmp(action,'initiate')
  bgc     = 'BackgroundColor';
  post    = 'Position';
  bgc1    = [0.8 0.8 0.8];
  bgc2    = [1 0 0];
  [mxs,nxs] = size(x);
  [mys,nys] = size(y);
  maxlvs  = min([mxs,nxs]);
  s1      = ['modlgui(0,0,''wird'','];
  modl    = [];

  handl   = zeros(10,12);
  fig00   = figure('Color',[0 0 0],'Numbertitle','Off','Name',...
   'Linear Model Builder',post,[11 19 480 320],'Resize','Off');
	
  frame2 = uicontrol(fig00,'Style','Frame',post,[11 131 220 110],bgc,bgc2);
  handl(1,2) = 3;
  handl(2,2) = uicontrol(fig00,'Style','Text',post,[15 135 212 102],...
   'String','Scaling',bgc,bgc1,'Userdata',[x]);	   
  handl(3,2) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String','  No Scaling',post,[50 195 170 20],...
   'Callback',[s1,'''act32'');']);
  handl(4,2) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String','  Mean Center',post,[50 170 170 20],...
   'Callback',[s1,'''act42'');']);
  handl(5,2) = uicontrol(fig00,'Style','Radio','Value',1,bgc,bgc1,...
   'String','  Autoscale',post,[50 145 170 20],...
   'Callback',[s1,'''act52'');']);

  frame3 = uicontrol(fig00,'Style','Frame',post,[11 11 220 110],...
   bgc,bgc2);
  handl(1,3) = 2;
  handl(2,3) = uicontrol(fig00,'Style','Text',post,[15 15 212 102],...
   'string','Linear Regression Method',bgc,bgc1,'Userdata',[y]);
  handl(3,3) = uicontrol(fig00,'Style','Radio','value',1,bgc,bgc1,...
   'String',' Partial Least Squares',post,[25 75 192 20],...
   'Callback',[s1,'''act33'');']);
  handl(4,3) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String',' Principal Components Regression',post,[25 50 192 20],...
   'callback',[s1,'''act43'');']);
  handl(5,3) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String',' Ridge Regression',post,[25 25 192 20],'Visible','Off',...
   'Callback',[s1,'''act53'');']);
  if (nys == 1)&(mxs > nxs)
    set(handl(5,3),'Visible','On')
  end

  frame4 = uicontrol(fig00,'Style','Frame',post,[11 251 460 60],...
   bgc,bgc2);
  handl(2,4) = uicontrol(fig00,'Style','Text',post,[15 255 452 52],...
   'String','Linear Regression Model Builder',bgc,[1 1 1]);

  frame5 = uicontrol(fig00,'Style','Frame',post,[251 61 220 180],...
   bgc,bgc2);
  handl(1,5) = 1;
  handl(2,5) = uicontrol(fig00,'Style','Text',post,[255 65 212 172],...
   'String','Cross-Validation Method',bgc,bgc1);
  handl(3,5) = uicontrol(fig00,'Style','Radio','Value',1,bgc,bgc1,...
   'String',' Venetian Blinds',post,[260 200 100 20],...
   'Callback',[s1,'''act35'');']);
  handl(4,5) = uicontrol(fig00,'Style','Radio','value',0,bgc,bgc1,...
   'String',' Leave One Out',post,[260 180 100 20],...
   'Callback',[s1,'''act45'');']);
  handl(5,5) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String',' Contiguous',post,[365 200 100 20],...
   'Callback',[s1,'''act55'');']);
  handl(6,5) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String',' Random',post,[365 180 100 20],...
   'Callback',[s1,'''act65'');']);
  handl(7,5) = uicontrol(fig00,'Style','Text',post,[255 65 212 172],...
   'String','Model Selection Method',bgc,bgc1,'Visible','Off');
  handl(8,5) = uicontrol(fig00,'Style','Radio','Value',1,bgc,bgc1,...
   'String',' Venetian Blinds',post,[260 200 100 20],...
   'Visible','Off','Callback',[s1,'''act85'');']);
  handl(9,5) = uicontrol(fig00,'Style','Radio','Value',0,bgc,bgc1,...
   'String',' Hoerl Kennard Esimate',post,[260 180 150 20],...
   'visible','Off','Callback',[s1,'''act95'');']);

  handl(2,6) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[291 141 110 20],'Horiz','Left','String','Max Lat Vars');   		  
  handl(3,6) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 161 140 18],'Min',1,'Max',maxlvs,'Value',maxlvs,...
   'Callback',[s1,'''act36'');']);
  handl(4,6) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 141 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,6),'Value')));
  handl(5,6) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 161 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,6),'Min')));
  handl(6,6) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[431 161 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,6),'Max')));
   			  
  handl(2,7) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[291 103 110 20],'Horiz','Left',...
   'String','Number of Splits');
   maxs = min([20,mxs]);
   vals = round(sqrt(mxs));
   vals = min([10,vals]);
  handl(3,7) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 123 140 18],'Min',2,'Max',maxs,'Value',vals,...
   'callback',[s1,'''act37'');']);
  handl(4,7) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 103 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,7),'Value')));
  handl(5,7) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 123 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,7),'Min')));
  handl(6,7) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[431 123 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,7),'Max')));

  handl(2,8) = uicontrol(fig00,'style','text',bgc,bgc1,...
   post,[291 65 110 20],'Horiz','Left',...
   'String','CV Repeats','Visible','off');   
  handl(3,8) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 85 140 18],'Min',1,'Max',20,'Value',5,...
   'callback',[s1,'''act38'');'],'visible','off');
  handl(4,8) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 65 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,8),'Value')),'Visible','Off');
  handl(5,8) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 85 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,8),'Min')),'Visible','Off');
  handl(6,8) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[431 85 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,8),'Max')),'Visible','Off');

  handl(2,9) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[291 103 110 20],'Horiz','Left',...
   'String','Theta Max','Visible','Off');
  handl(3,9) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 123 140 18],'Min',0.01,'Max',1,'Value',0.1,...
   'callback',[s1,'''act39'');'],'Visible','Off');
  handl(4,9) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 103 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,9),'Value')),'Visible','Off');
  handl(5,9) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 123 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,9),'Min')),'Visible','Off');
  handl(6,9) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[431 123 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,9),'Max')),'Visible','Off');

  handl(2,10) = uicontrol(fig00,'style','text',bgc,bgc1,...
   post,[291 65 110 20],'Horiz','Left',...
   'String','Number of Divs','Visible','off');   
  handl(3,10) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 85 140 18],'Min',1,'Max',50,'Value',10,...
   'callback',[s1,'''act310'');'],'visible','off');
  handl(4,10) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 65 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,10),'Value')),'Visible','Off');
  handl(5,10) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 85 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,10),'Min')),'Visible','Off');
  handl(6,10) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[431 85 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,10),'Max')),'Visible','Off');

  handl(2,11) = uicontrol(fig00,'style','text',bgc,bgc1,...
   post,[291 141 110 20],'Horiz','Left',...
   'String','Number of Splits','Visible','off');
   maxs = min([20,mxs]);
   vals = round(sqrt(mxs));
   vals = min([10,vals]);
  handl(3,11) = uicontrol(fig00,'Style','Slider',bgc,bgc1,...
   post,[291 161 140 18],'Min',2,'Max',maxs,'Value',vals,...
   'callback',[s1,'''act311'');'],'visible','off');
  handl(4,11) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[401 141 30 20],'Horiz','Right','String',...
   num2str(get(handl(3,11),'Value')),'Visible','Off');
  handl(5,11) = uicontrol(fig00,'Style','Text',bgc,bgc1,...
   post,[261 161 30 20],'Horiz','Left','String',...
   num2str(get(handl(3,11),'Min')),'Visible','Off');
  handl(6,11) = uicontrol(fig00,'Style','Text',bgc,bgc1,...

⌨️ 快捷键说明

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