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 CenterFile Exchange에서 Dimensionality 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