how to use PCA coefficients (princomp)

3 ビュー (過去 30 日間)
A
A 2012 年 12 月 10 日
回答済み: Aditya 2025 年 2 月 8 日 17:30
I have matrix of 10000 rows and 500 columns where rows are observations and columns for features. The data is for three different classes (appx 3300 samples of each class). Now I want to apply princomp for PCA to reduce dimension of data. The coefficients matrix results in 500X500 and score is same matrix dimension as original (10000X500).
Kindly help me how can I modify my original data (10000X500) using coefficients and score matrices ? what is the procedure?
Thanks and in advance!

回答 (1 件)

Aditya
Aditya 2025 年 2 月 8 日 17:30
Hi A,
To apply Principal Component Analysis (PCA) using MATLAB's princomp (or the updated pca function), and then transform your original data into a reduced-dimensionality space, follow these steps:
% Assume your data matrix is named 'dataMatrix' with size 10000x500
[coeff, score, latent, tsquared, explained, mu] = pca(dataMatrix);
cumulativeVariance = cumsum(explained);
plot(cumulativeVariance);
xlabel('Number of Principal Components');
ylabel('Cumulative Explained Variance (%)');
% Choose the number of components to keep
k = 50; % for example, keep the first 50 components
% Transform the original data
reducedData = score(:, 1:k);
% Reconstruct the data from the reduced dimensions
reconstructedData = reducedData * coeff(:, 1:k)' + mu;

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by