kpcademo1.m

来自「支持向量机作为统计学习理论的实现方法」· M 代码 · 共 67 行

M
67
字号
echo on;
% KPCADEMO1 demo on the Kernel-PCA.

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Modifications:% 8-July-2001, V.Franc 
% First, we load data from file. Use 'creatset' to interactively 
% create your own data in 2D.
pause;  % press anykey
data=load('pcaexam1');

% The Kernel-PCA non-linearly map the data into high dimensional 
% space and then reduces their dimension by linear (standard) PCA.
%
% The points in the original space which have the equal value of 
% extracted feature form contours. The contours show main variance 
% in the data. These contours can be displayed by pkernelpca function.
% 
% We display two features of the original 2D space and then
% two features (principal components) after linear, RBF (sigma =1)
% and polynomial (d=2) mapping. The first component si denoted by
% red and the second by blue color.
pause;  % press anykey
% Plot the points with the equal coordinates x and y
figure;
subplot(2,2,1);
hold on;
ppoints(data.X,data.I);                
title('Orginal space');

w = axis;
for i = w(1):(w(2)-w(1))/8:w(2),   
   plot([i i],[w(3),w(4)],color(1));
   echo off;
end
for j = w(3):(w(4)-w(3))/8:w(4),
   plot([w(1) w(2)],[j j],color(2));
end
echo on;

% Linear PCAsubplot(2,2,2);
hold on;
ppoints(data.X,data.I);        % display data
title('Linear PCA');
pkernelpca(data.X,[1,2],'linear',[]);

% RBF mapping, PCA
subplot(2,2,3);
hold on;
ppoints(data.X,data.I);        % display data
title('RBF(sigma = 1), PCA');
pkernelpca(data.X,[1,2],'rbf',[0.5]);

% Polynomial mapping, PCA
subplot(2,2,4);
hold on;
ppoints(data.X,data.I);        % display data
title('Polynom (d = 2), PCA');
pkernelpca(data.X,[1,2],'poly',[2]);

echo off;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?