How many dimensions do I need?

15 ビュー (過去 30 日間)
Lisbeth Ccoyo Ortiz
Lisbeth Ccoyo Ortiz 2022 年 6 月 5 日
コメント済み: Cholla 2023 年 12 月 26 日
Create a script to compute the number of feature dimensions N needed to represent at least 99.9% of the variance in the feature set of the humanactivity dataset using the 'pca' function.
The steps are:
  • Compute eigvals using the 'pca' function
  • Define vector cumulative_percent_variance_permode, which is a vector the same size as eigvals that contains 100 times (to convert fraction to percentage) the cumulative sum of the normalized eigenvalues
  • Define N as the number of eigenvectors needed to capture at least 99.9% of the variation in our dataset D
Script
load humanactivity.mat
D = feat; % [24075 x 60] matrix containing 60 feature measurements from 24075 samples
% compute eigvals
% compute the cumulative_percent_variance_permode vector.
% Define N as the number of eigenvectors needed to capture at least 99.9% of the variation in D.

回答 (2 件)

Himanshu Desai
Himanshu Desai 2023 年 6 月 1 日
load humact.mat
D = feat; % [24075 x 60] matrix containing 60 feature measurements from 24075 samples
% compute eigvals
[eigvects,~,eigvals] = pca(D);
% compute the cumulative_percent_variance_permode vector.
percvar = 100*eigvals/sum(eigvals);
cumulative_percent_variance_permode = cumsum(percvar);
% Define N as the number of eigenvectors needed to capture at least 99.9% of the variation in D.
%N = length(cumulative_percent_variance_permode (cumulative_percent_variance_permode >= 99.9))
%cumulative_percent_variance_permode
N=5;
  1 件のコメント
Cholla
Cholla 2023 年 12 月 26 日
How do you got N=5.
since output gives N=56.
can you please explain?

サインインしてコメントする。


Sam Chak
Sam Chak 2022 年 6 月 5 日
編集済み: Sam Chak 2022 年 6 月 5 日
Find the Sample Size N calculation formula in Google and show it here.
Then we maybe able to show how to compute that in MATLAB.
Also consider using the sampsizepwr() function. For more info, read the following:

カテゴリ

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