how to use PCA coefficients (princomp)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (1)
Aditya
el 8 de Feb. de 2025 a las 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;
0 comentarios
Ver también
Categorías
Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!