From 8b3fbea0028937fa6461fbe4c6c30c4db0944cc3 Mon Sep 17 00:00:00 2001 From: Lillian Weng Date: Thu, 18 Apr 2024 17:45:20 -0700 Subject: [PATCH] fix images pca II --- {pca_1 => pca_2}/images/lin_reg.png | Bin {pca_1 => pca_2}/images/lin_reg_reverse.png | Bin {pca_1 => pca_2}/images/rank1.png | Bin pca_2/pca_2.qmd | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename {pca_1 => pca_2}/images/lin_reg.png (100%) rename {pca_1 => pca_2}/images/lin_reg_reverse.png (100%) rename {pca_1 => pca_2}/images/rank1.png (100%) diff --git a/pca_1/images/lin_reg.png b/pca_2/images/lin_reg.png similarity index 100% rename from pca_1/images/lin_reg.png rename to pca_2/images/lin_reg.png diff --git a/pca_1/images/lin_reg_reverse.png b/pca_2/images/lin_reg_reverse.png similarity index 100% rename from pca_1/images/lin_reg_reverse.png rename to pca_2/images/lin_reg_reverse.png diff --git a/pca_1/images/rank1.png b/pca_2/images/rank1.png similarity index 100% rename from pca_1/images/rank1.png rename to pca_2/images/rank1.png diff --git a/pca_2/pca_2.qmd b/pca_2/pca_2.qmd index 587080e9..7f66c2a3 100644 --- a/pca_2/pca_2.qmd +++ b/pca_2/pca_2.qmd @@ -634,7 +634,7 @@ $$ \text{component score} = \frac{s_i^{2}}{N}$$ $$ \text{total variance} = \text{sum of all the component scores} = \sum\_{i=1}^k \frac{s_i^{2}}{N} $$ -$$ \text{variance ratio of principal component i} = \frac{\text{component score i}}{\text{total variance}} = \frac{s*i^{2} / N}{\sum*{i=1}^k s_i^{2} / N}$$ +$$ \text{variance ratio of principal component j} = \frac{\text{component score j}}{\text{total variance}} = \frac{s_j^{2} / N}{\sum_{i=1}^k s_i^{2} / N}$$ In Python, assuming you had a 1D `NumPy` array of singular values `s` returned by `np.linalg.svd`, you could compute the list of variances ratios with `s**2 / sum(s**2)`.