资源简介
文件内包含KRR、KPCA、KPCR以及KPLS的相关程序,其中KPLS相关程序又包括KerSIMPLS以及KerNIPALS可供选择,他们是用不同方法计算的PLS。同时文件中还有一个例子,分别应用这些程序实现sin函数的拟合,清晰易懂。
代码片段和文件信息
function [P_XP_XtD]=EM_KPCA(XXtn_pctypepar1par2)
% Threshold for norm difference in E-M
Epsilon = 0.005;
%%% Expectation Maximization Kernel Principal Component Analysis
%%%
%%% Inputs
% X : training data points (number of samples x dimension)
% Xt : testing data points (number of samples x dimension)
%
% n_pc : number of principal componets onto which data are projected
%
% par1 par2
% type: ‘G‘ Gaussian Kernel exp((|x-y|^2)/w) w 0
% ‘P‘ Polynomial Kernel (+c)^a: a c
%
%% Output
% P_X : projection of training data onto the first n_pc principal componets (number of samples x n_pc)
% P_Xt : projection of testing data onto the first n_pc principal componets (number of samples x n_pc)
%
% D : eigenvalues of the centralized (cen_K) training data kernel matrix
% : !!!! eigenvalues coresponding to the sample covariance matrix are sqrt(D)/(n-1)
[ndim]=size(X);
[ntdim]=size(Xt);
%%% training data kernel matrix construction
K=Kernel(Xtypepar1par2);
%%% centering of K
M=eye(n)-ones(nn)/n;
cen_K=M*K*M;
%%% EM-KPCA
%%% in contrast to the NC paper there is a change in notation : X <--> Y
Gamma=randn(nn_pc); %%% random intialization
iter=1;
err(1)=Epsilon+1;
while err(iter) > Epsilon
% iter
%%%%% E-step
LC=Gamma‘*cen_K;
Y=inv(LC*Gamma)*LC;
%%%%% M-step
Gamma_old=Gamma;
Gamma=Y‘*inv(Y*Y‘);
iter=iter+1;
err(iter)=norm(Gamma_old-Gamma);
end
%%% getting eigenvalues
ort_Gamma=orth(Gamma);
Y=cen_K*ort_Gamma;
[VD]=eig(cov(Y));
[Dind]=sort(diag(D)*(n-1));
D=flipud(D);
ind=flipud(ind);
V=V(:ind); %%% sorting eigenvectors
YV=Y*V; %%% rotation to Kernel PCA
%%% training data projection
P_X=YV;
%%% TESTING PART
% testing data kernel matrix construction
Kt=Kernel_Test(XXttypepar1par2);
%%% centering of Kt
Mt=ones(ntn)/n;
cen_Kt = (Kt - Mt*K)*M;
%%% testing data projection
P_Xt=cen_Kt*ort_Gamma*V;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1449 2003-04-21 18:07 PLS_SIMPLS.m
文件 2430 2003-04-21 18:07 EM_KPCA.m
文件 5465 2003-04-23 16:10 example.m
文件 851 2003-04-21 18:07 Kernel.m
文件 922 2003-05-22 21:13 Kernel_Test.m
文件 1534 2003-04-21 18:07 KerNIPALS.m
文件 1575 2003-04-21 18:07 KerPLS_eig.m
文件 1122 2003-04-21 18:07 KerSIMPLS1.m
文件 1216 2003-04-23 16:10 KerSIMPLS.m
文件 813 2003-04-21 18:07 KerSIMPLS_Test.m
文件 2154 2003-04-21 18:07 KPCA.m
文件 1165 2003-04-21 18:07 KPCR.m
文件 1084 2003-04-21 18:07 KPCR_cent.m
文件 1521 2003-04-21 18:07 KRR_cent.m
文件 1228 2003-04-21 18:07 PCR_cent.m
文件 624 2003-04-21 18:07 PLS_SB.m
----------- --------- ---------- ----- ----
25153 16
- 上一篇:数字通信(第五版本)
- 下一篇:获取系统管理员密码和账号findpass
评论
共有 条评论