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

📄 gclearngress.m

📁 这是一个支持向量机的工具
💻 M
字号:
function [Gb,nuopt,Rmanifold,sigmb]=gclearngress(X,Z,nus,vmax,Xlabel,aics,zchoise,method)
% data geometrization and model construction from curve manifolds


%(1) data geometrization to curve manifold Mx via n local curves
% searching optimal geometrization under different parameters nu
k=0;
for nu=nus
   k=k+1;
  % k variables are geometrized into k curve manifolds by nu
  [Xcurve,bx,v,vend]=datageometrize(X,nu,0);
  v=[v;v(length(v))+1];
  manifolds=Xcurve;
  % use true values of Z instead of the curve
  if zchoise=='zvalue'  manifolds(:,Z)=X(:,Z); end

%(2) constructing models from curve manifolds
% models Ga{i} with Z as response variable; sigma: fitting variance of Ga{i}
if method=='outdata'
  if length(Xlabel)>1 manifolds=manifolds(Xlabel,:);end
  [ph,id]=sumdata(manifolds);     % computing curve(i)*curve(j)
  np=size(manifolds,1);
  region{1}=[1 1 0 0 np];
else
% sum elements of geometric entity p & h for every Ui
  [p,pp,ph,id]=sumcurve(bx,v,vend,'each');
  if length(Xlabel)>1 
     p=p(Xlabel,:);
     pp=pp(Xlabel,:);
     ph=ph(Xlabel,:);
     %p=integralsum(p,nu,0);
  end
  np=size(p,1);
  region{1}=[1 1 0 0 np];
end

for i=Z
 if method=='outdata'
   [Q,R,S]=modeloutdata(region{1},manifolds,ph,id,i,vmax);
 else
   [Q,R,S]=modeloutframe(v,region{1},p,pp,ph,id,i,vmax);
 end
 Ga{i}=Q; sigma{i}=R; 
 Kn{i}=S;                        % number of model parameters
end

if aics=='minsigm'
  [T,S]=min(R);
  if k==1
    Gb=Q(S,:); 
    sigmb=T;
    nuopt=nu;  
    Rmanifold=Xcurve;
  elseif T<sigmb
    Gb=Q(S,:); 
    sigmb=T;
    nuopt=nu;  
    Rmanifold=Xcurve;
  end
  
else
% model selection by a criterion based on sigma
[G,Aid]=modelselect(Z,region,Ga,Kn,sigma,'aic');

% choose a best model under different nu by finding min sigma
for i=Z
  Q=G{i}; 
  R=Aid{i};               % min sigm stored in Aid (row 3)
  if k==1
    Gb{i}=Q; sigmb{i}=R;
    nv(i)=size(Gb{i},1);
    nuopt=nu;  
    Rmanifold=Xcurve;
  else
    S=sigmb{i}; T=Gb{i};
    for j=1:nv(i)
      if R(3,j)<S(3,j)
       S(3,j)=R(3,j); 
       T(j,:)=Q(j,:);
       nuopt=nu; 
       Rmanifold=Xcurve;
      end
    end
    sigmb{i}=S;
    Gb{i}=T;
  end
end % end i

end % if method

end % end nu


if iscell(Gb) Gb=Gb{Z}; sigmb=sigmb{Z}; end


function  T=integralsum(ph,nu,k)
% sum k pieces of integral curve

if k>0 nu=k; end
[n1,n2]=size(ph);
for j=1:n2
  np=ceil(n1/nu);
  S=zeros(np*nu,1);
  S(1:n1,1)=ph(:,j);
  T(:,j)=(sum(reshape(S,nu,np)))';
end

⌨️ 快捷键说明

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