-2

你好我用MATLAB做PCA,下面的代码(我有13个属性)实际上我在运行程序(RBF网络)时遇到了问题,所以我用PCA来调整数据,我可以用这个方法吗?如果是,我应该使用矩阵 als 而不是我的真实数据吗?

% PCA1: Perform PCA using covariance.

% data - MxN matrix of input data

% (M dimensions, N trials)

% signals - MxN matrix of projected data

% PC - each column is a PC

% V - Mx1 matrix of variances

[M,N] = size(data);

% subtract off the mean for each dimension

mn = mean(data,2);

data = data - repmat(mn,1,N);

% calculate the covariance matrix

covariance = 1 / (N-1) * data * data’;

% find the eigenvectors and eigenvalues

[PC, V] = eig(covariance);

% extract diagonal of matrix as vector

V = diag(V);

% sort the variances in decreasing order

[junk, rindices] = sort(-1*V);

V = V(rindices);

PC = PC(:,rindices);

% project the original data set

sign

als = PC’ * data;

谢谢

4

1 回答 1

0

是的,矩阵als是新的转换数据集。为了控制这个新数据的维数,你可以通过取最重要的k向量来修改PC;

PC = PC(:,1:k);

为了找到新样本的转换等效项X(N x 1),您可以编写:

X_transformed = PC’ * X;
于 2013-06-26T17:15:30.787 回答