- Normalization
- Interpreting PCA Components
How to interpret an answer given by PCA
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have matrix consisted of 30 variables(columns) and 14 observation(rows). Many of these variables are basically measuring similar activities. Thus I decided to use PCA to decrease the dimensionality.
There are two major problem:
1- These variables have different unites some are time values and some are number of repetitions. can I use the row data for PCA, or do I need to normalize them beforehand? In the latter case, what would be the best way of normalization?
2- If I decided to take the first two pca components how could I find out which variables are explained by which component? You can find it out by SPSS, but I would not know how to do it by MATLAB.
your helps would be highly appreciated,
cheers
Yoolla
0 Kommentare
Antworten (1)
Aditya
am 8 Feb. 2025
Hi Yoolla,
When performing PCA, especially with variables measured in different units, it's crucial to ensure that the data is properly prepared. Here's how you can address the issues you've mentioned:
% Assume your data matrix is named 'dataMatrix' with size 14x30
normalizedData = zscore(dataMatrix);
% Min-Max Scaling
minVals = min(dataMatrix);
maxVals = max(dataMatrix);
scaledData = (dataMatrix - minVals) ./ (maxVals - minVals);
% Perform PCA on the normalized data
[coeff, score, latent, tsquared, explained] = pca(normalizedData);
% Display the coefficients for the first two principal components
disp('Coefficients for the first two principal components:');
disp(coeff(:, 1:2));
% You can also visualize the loadings
figure;
biplot(coeff(:, 1:2), 'Scores', score(:, 1:2), 'VarLabels', arrayfun(@(x) sprintf('Var%d', x), 1:size(dataMatrix, 2), 'UniformOutput', false));
title('Biplot of First Two Principal Components');
xlabel('Principal Component 1');
ylabel('Principal Component 2');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!