📄 os2m.m
字号:
function[RMSEC,ypcal,RMSEP,ypval,b,c]=os2m(Tcal,y,noll,Tval,yval,disp);% [RMSEC,ypcal,RMSEP,ypval,b,c]=os2m(Tcal,y,noll,Tval,yval,disp);% % Optimized scaling 2, T. V. Karstang, R. Manne, Chemolab 14 (1992) 165-173% Uses scores T from pca, non sentered, instead of matrix X%% Input: % T(scores) - calibration set% y(response) - calibration set% noll(scalar) - reference spectra % Tval=Xval*P - scores validation set% yval - response validation set% if plot then the result is displayed%% Prediction of new samples: ypred=(T*b)./(T*c);%%% M-file given by R. Manne. Modified by L. Stordrange 06.06.01[i,j]=size(Tcal);m=size(Tval,1);T=Tcal;xnull=T(noll,:); ynull=y(noll);Z=diag(y)*T;Z(noll,:)=zeros(1,j);ZX=[Z T];xnull0=[xnull,zeros(1,j)];% The final system of linear equations is denoted A*p=qA=[ZX'*ZX,xnull0';xnull0,0];q=[zeros(j,1);-ynull*xnull';1];p=A\q; c=p(1:j);b=-p(j+1:2*j);%lamda=-p(2*j+1);ypcal=(T*b)./(T*c);e=y-ypcal;RMSEC=sqrt((e'*e)/i);po=polyfit(y,ypcal,1);if nargin>5 xi=linspace(min(y)*0.8,max(y)*1.2,4); z=polyval(po,xi); subplot(1,2,1) plot(y,ypcal,'.',xi,z),xlabel('y measured'),ylabel('y predicted') subplot(1,2,2) bar(e),xlabel('object #'),ylabel('residual')end% Predikerer valideringspr鴙erypval=(Tval*b)./(Tval*c);e=yval-ypval;RMSEP=sqrt((e'*e)/m);figurepo=polyfit(yval,ypval,1);if nargin>5 xi=linspace(min(y)*0.8,max(yval)*1.2,4); z=polyval(po,xi); subplot(1,2,1) plot(yval,ypval,'.',xi,z),xlabel('y measured'),ylabel('y predicted') subplot(1,2,2) bar(e),xlabel('object #'),ylabel('residual')end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -