⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spca.m

📁 this a SVM toolbox,it is very useful for someone who just learn SVM.In order to be undestood easily,
💻 M
字号:
function [T,sumeigv,eigv] = spca(X,m,method)% SPCA Principal Component Analysis.%  [T,sumeigv,eigv] = spca(X,m,method)%% SPCA is the standard Principal Componets Analysis (PCA). %   The original d-dimensional feature space is reduced into %   new m-dimensional space (m < d) by a linear transfomation%          y = T*x%%   where x is d-dimensional vector from the original space and%   y is m-dimensional from the reduced space. The rows of the 
%   matrix T contains eigenvetors of covariance matrix of data X.
%   The eigenvectors are ordered according to their eigenvalues 
%   in descending order.%%   Two methods of decomposition to eigenspace are used:%     1) method = 'default'  uses eig( cov( X' )), better for d << l%     2) method = 'ecov'  uses ecov (see help ecov), better for d >> l%   where l is the number of input data.%% Input: %  X [d x l] contains l vectors which decribe the original %          d-dimensional feature space.%  m [1 x 1] is dimension of the reduced feature space which has %          to be less or equal to min(N,K).%  method [string] method of eigenvalue decomposition,%     'default' for eig(cov(X')), 'ecov' for ecov(X).%% Output:%  T [m x d] is the transformation matrix.%  sumeigv [1 x 1] is the error of used transformation, which is %          equal to the value of the minimized objective fuction.%  eigv [d x 1] contains sorted eigenvalues.
%
% See KENELPCA.
%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis) 19.06.00% Modifications% 21-may-2001, V.Franc, ecov method added% 21-dec-2000l=size(X,2);
if nargin < 2, 
   m = size(X,1);
end
if nargin < 3 | strcmpi( method, 'default') == 1,   [V,D]=eig(cov(X'));   [eigv,inxDesc]=sort(-diag(D));   eigv=-eigv;   T=V(:,inxDesc);else  [V,eigv] = ecov( X );    if m > length( eigv ),    disp('Desired data dimension is too big.');    T = V;  endendsumeigv=sum(eigv(m+1:end));
T = V(:,1:m)';

return;

⌨️ 快捷键说明

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