- Plotting the eigenvalues:
How can I Perform Dimensionality Reduction of my Data using PCA?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I have collected some data over time and have organized it in a matrix where every row denotes a voltage value for a specific human cell. So, since I have a number of cells to describe, this number is also equal to the number of rows. Each column represents a "time bin". I need to perform dimensionality reduction of this multivariate time series using PCA. I have obtained the covariance matrix as well as its eigenvalues and eigenvectors and here's where my question lies.
How do I then proceed to understand if I have reduced dimensionality? Is it possible to plot the eigenvalues, and how do I understand/visualize how many dimensions are enough to describe my data under PCA? Also, if we consider the population vector that describes the voltage for every human cell at each time step or "time bin", can I plot its trajectory in 2 or 3 dimensions?
0 comentarios
Respuestas (1)
Aniketh
el 8 de Jul. de 2023
Hi, to understand if you have successfully reduced the dimensionality of your multivariate time series using PCA, you can analyze the eigenvalues obtained from the covariance matrix. Here's how you can proceed:
eigenvalues = eig(covariance_matrix);
explained_variance = eigenvalues / sum(eigenvalues); % Normalize eigenvalues to calculate explained variance
cumulative_variance = cumsum(explained_variance);
% Scree plot
figure;
plot(1:length(eigenvalues), eigenvalues, 'o-');
xlabel('Principal Component');
ylabel('Eigenvalue');
title('Scree Plot');
% Cumulative variance plot
figure;
plot(1:length(cumulative_variance), cumulative_variance, 'o-');
xlabel('Number of Principal Components');
ylabel('Cumulative Explained Variance');
title('Cumulative Variance Plot');
Plotting the trajectory in 2 or 3 dimensions:
% Select the desired number of principal components for projection
num_components = 2; % Or 3 for 3D visualization
projection_matrix = eigenvectors(:, 1:num_components);
% Project the data onto the lower-dimensional space
projected_data = original_data * projection_matrix;
% Plot the trajectory in 2D or 3D
figure;
if num_components == 2
plot(projected_data(:, 1), projected_data(:, 2), 'o-');
xlabel('Principal Component 1');
ylabel('Principal Component 2');
title('Population Trajectory in 2D');
elseif num_components == 3
plot3(projected_data(:, 1), projected_data(:, 2), projected_data(:, 3), 'o-');
xlabel('Principal Component 1');
ylabel('Principal Component 2');
zlabel('Principal Component 3');
title('Population Trajectory in 3D');
end
0 comentarios
Ver también
Categorías
Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!