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

📄 pcpred.m

📁 王小平《遗传算法——理论、应用与软件实现》随书光盘
💻 M
字号:
function [pred,impact]=pcrpred(x,c,tx,ty,n)
%
% predicts system output given the coefficients
% of the principal components, and the number
% of components to include.
%
% MUST BE GIVEN SCALED DATA
%

%
% Build correct sized set of coefficients
%
cs=c(:,1:n);

%
% calculate the principal components
%
pcs=tx*cs;
size(pcs);
%
% calculate the regression vector
%
a=inv(pcs'*pcs)*pcs'*ty;

%
% Calculate the output
%
pred=x*cs;

pred=pred*a;

%
% Now calculate the impact of each variable
% (ie its overall regression vector
%
[D L]=size(x);
impact=zeros(1,L);

for i = 1:L
	for j = 1:n
		impact(i)=impact(i)+cs(i,j)*a(j);
	end
end

⌨️ 快捷键说明

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