资源简介
注释详细,易于使用,程序经典!可供非线性线性变换、特征降维使用
代码片段和文件信息
% Kernel PCA toy example for k(xy)=exp(-||x-y||^2/rbf_var) cf. Fig. 4 in
% @article{SchSmoMue98
% author = “B.~{Sch\“olkopf} and A.~Smola and K.-R.~{M\“uller}“
% title = “Nonlinear component analysis as a kernel Eigenvalue problem“
% journal = {Neural Computation}
% volume = 10
% issue = 5
% pages = “1299 -- 1319“
% year = 1998}
% This file can be downloaded from http://www.kernel-machines.org.
% Last modified: 4 July 2003
% parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rbf_var = 0.1;
xnum = 4;
ynum = 2;
max_ev = xnum*ynum;
% (extract features from the first Eigenvectors)
x_test_num = 15;
y_test_num = 15;
cluster_pos = [-0.5 -0.2; 0 0.6; 0.5 0];
cluster_size = 30;
% generate a toy data set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num_clusters = size(cluster_pos1);
train_num = num_clusters*cluster_size;
patterns = zeros(train_num 2);
range = 1;
randn(‘seed‘ 0);
for i=1:num_clusters
patterns((i-1)*cluster_size+1:i*cluster_size1) = cluster_pos(i1)+0.1*randn(cluster_size1);
patterns((i-1)*cluster_size+1:i*cluster_size2) = cluster_pos(i2)+0.1*randn(cluster_size1);
end
test_num = x_test_num*y_test_num;
x_range = -range:(2*range/(x_test_num - 1)):range;
y_offset = 0.5;
y_range = -range+ y_offset:(2*range/(y_test_num - 1)):range+ y_offset;
[xs ys] = meshgrid(x_range y_range);
test_patterns(: 1) = xs(:);
test_patterns(: 2) = ys(:);
cov_size = train_num; % use all patterns to compute the covariance matrix
% carry out Kernel PCA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:cov_size
for j=i:c
- 上一篇:Chameleon算法Matlab实现
- 下一篇:Z变换和差分方程的Matlab求解
评论
共有 条评论