标签:
核主成分kpcapca机器学习聚类 |
分类: 学科知识 |
% 3.3 Kernel Principal Component Analysis
clc
clear
close all
% generate circle data
X = gencircledata([1;1],5,250,1);
% compute kernel PCA
options.ker = 'rbf'; % use RBF kernel
options.arg = 4; % kernel argument
options.new_dim = 2; % output dimension
model = kpca(X,options);
XR = kpcarec(X,model); % compute reconstruced data
% Visualization
figure;
h1 = ppatterns(X);
h2 = ppatterns(XR, '+r');
legend([h1 h2],'Input vectors','Reconstructed');
% 3.3 Kernel Principal Component Analysis
clc
clear
close all
% generate circle data
X0 = gencircledata([1;1],1,250,0.1);
X1 = gencircledata([1;1],3,250,0.1);
X2 = gencircledata([1;1],6,250,0.1);
X0 = X0 - repmat(mean(X0, 2), 1, 250);
X1 = X1 - repmat(mean(X1, 2), 1, 250);
X2 = X2 - repmat(mean(X2, 2), 1, 250);
X = [X0 X1 X2];
y = [ones(1, size(X0, 2)) 2*ones(1, size(X1, 2)) 3*ones(1, size(X2,
2))];
data.X = X;
data.y = y;
figure
ppatterns(data);
% compute kernel PCA
kernelflag = 1;
if kernelflag == 1
elseif kernelflag == 2
else
end
options.new_dim = 2; % output dimension
model = kpca(data.X, options);
kpca_data = kernelproj(data, model);
figure
ppatterns(kpca_data);