使用PCA算法调整数据

时间:2013-06-26 15:22:05

标签: matlab pca

你好我用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;

由于

1 个答案:

答案 0 :(得分:0)

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

PC = PC(:,1:k);

为了找到新样本X(N乘1)的转换后的等价物,你可以写:

X_transformed = PC’ * X;