資源簡介
主成分回歸在matlab上的實現,有詳細介紹,簡單易懂。
代碼片段和文件信息
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?是自變量數據,y?是要回歸的因變量
%???標準化輸入數據矩陣
%???m?是主成分個數?sum?是累積貢獻率
%???xmean?是輸入數據均值,xstd?是輸入數據方差
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
%???計算主成
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1737??2015-06-28?20:43??PCR.m
評論
共有 條評論