資源簡(jiǎn)介
主成分回歸在matlab上的實(shí)現(xiàn),有詳細(xì)介紹,簡(jiǎn)單易懂。
代碼片段和文件信息
function??[coeffs2]?=?PCR(x??y)
%*******************************************************
%???This?programme?is?designed?by?Zi???????????????????%
%???Version?1.0?completed?in?200942??????????????????%
%???Copyright?2009WZZYIncEmail:xinlangwzzy@sina.com?%
%???Protected?by?Zihao?Wang.???????????????????????????%
%*******************************************************
%???PCR?Summary?of?this?function?goes?here
%???x?是自變量數(shù)據(jù),y?是要回歸的因變量
%???標(biāo)準(zhǔn)化輸入數(shù)據(jù)矩陣
%???m?是主成分個(gè)數(shù)?sum?是累積貢獻(xiàn)率
%???xmean?是輸入數(shù)據(jù)均值,xstd?是輸入數(shù)據(jù)方差
m?=?1;
sum?=?0;
xmean?=?mean(x);
xstd?=?std(x);
xstandar?=?zscore(x);
[pcscorelatenttsqure]?=?princomp(xstandar);
for?i?=?1?:?length(latent)
????sum?=?latent(i)?+?sum;
????if?sum/length(latent)?>=?0.85
????????m?=?i;
????????break;
????end
end
%???計(jì)算主成
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????1737??2015-06-28?20:43??PCR.m
評(píng)論
共有 條評(píng)論