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

📄 splspred.m

📁 偏最小二乘算法在MATLAB中的实现
💻 M
字号:
function ypred = splspred(newx,P,W,C,cfs,ks,lvs,plots)
%SPLSPRED Predictions based on existing SPL_PLS model
%  This function is used to make predictions based on an existing
%  spline-pls model as identified by the spl_pls function.  
%  Inputs are the matrix of new independent variables (xnew), the
%  x-block loadings (P), x-block weights (W), inner coefficients
%  (C), spline coeficients (cfs), knot locations (ks), the number
%  of latent variables to consider (lvs) and the optional variable
%  (plots) which supresses all plots when set to 0.  The output is
%  the predicted values of the new samples (ypred).
%  I/O format is: ypred = splspred(newx,P,W,C,cfs,ks,lvs,plots);

%  Copyright
%  Barry M. Wise
%  1992
%  Modified April 1994
if nargin == 7
  plots = 1;
end
[mx,nx] = size(newx);
[mC,nC] = size(C);
yvars = mC/nC;
ypred = zeros(mx,yvars);
U = zeros(mx,lvs);
[mcfs,ncfs] = size(cfs);
[mks,nks] = size(ks);
deg = mcfs-1;
knots = mks;
E = newx;
for i = 1:lvs
  t = E*W(:,i);
  U(:,i) = splnpred(t,cfs(1:mcfs,(mks+1)*(i-1)+1:(mks+1)*i),ks(:,i),0);
  if plots == 1
    plot(U(:,1:i)*C(yvars*(i-1)+1:yvars*i,1:i)')
    s = sprintf('Predicted dependent variables based on %g LVs',i);
    title(s)
	drawnow
  end
  E = E - t*P(:,i)';
end
ypred = U*C(yvars*(lvs-1)+1:yvars*lvs,1:lvs)';
  

⌨️ 快捷键说明

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