{"id":6766,"date":"2026-08-11T21:02:09","date_gmt":"2026-08-12T02:02:09","guid":{"rendered":"https:\/\/ykim.synology.me\/wordpress\/?p=6766"},"modified":"2026-11-26T22:38:28","modified_gmt":"2026-11-27T04:38:28","slug":"pca-derivation","status":"publish","type":"post","link":"https:\/\/ykim.synology.me\/wordpress\/pca-derivation-6766\/","title":{"rendered":"PCA Derivation"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/yBarn1\/Images\/main\/ice-rinks\/apex-ice-arena-rink.jpg\" alt=\"\" style=\"width:auto;height:500px\"\/><\/figure>\n\n\n<p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"Feature-Engineering\/PCA\/pca-derivation.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">PCA Derivation<\/h1><a id=\"user-content-pca-derivation\" class=\"anchor\" aria-label=\"Permalink: PCA Derivation\" href=\"#pca-derivation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 9 | Created: 2026-08-11 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-notation\">1. Notation<\/a><\/li>\n<li><a href=\"#2-the-objective\">2. The Objective<\/a><\/li>\n<li><a href=\"#3-the-lagrange-condition\">3. The Lagrange Condition<\/a><\/li>\n<li><a href=\"#4-the-choice-among-stationary-points\">4. The Choice Among Stationary Points<\/a><\/li>\n<li><a href=\"#5-the-later-components\">5. The Later Components<\/a><\/li>\n<li><a href=\"#6-the-reconstruction-view\">6. The Reconstruction View<\/a><\/li>\n<li><a href=\"#7-the-bridge-to-the-svd\">7. The Bridge To The SVD<\/a><\/li>\n<li><a href=\"#8-a-worked-example\">8. A Worked Example<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-the-worked-example-drawn\">Appendix B. The Worked Example Drawn<\/a><\/li>\n<li><a href=\"#appendix-c-the-column-wise-orthonormal-matrix\">Appendix C. The Column-wise Orthonormal Matrix<\/a><\/li>\n<\/ul>\n<blockquote>\n<p dir=\"auto\">The procedure can be followed without knowing why its answer is right, and most uses never need to ask.\nThis document is for when the question comes up: it derives, from the requirement of keeping as much variance as possible, that the axes PCA returns must be eigenvectors of the covariance matrix.<\/p>\n<\/blockquote>\n<p dir=\"auto\">The whole derivation is one constrained maximization solved with a Lagrange multiplier, and it is short enough to check line by line. Working through it settles why centering is mandatory, why an eigenvalue is itself a variance, why the components come out ordered and orthogonal without anyone asking for that, and why maximizing the kept variance and minimizing the reconstruction error are the same act.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Notation<\/h2><a id=\"user-content-1-notation\" class=\"anchor\" aria-label=\"Permalink: 1. Notation\" href=\"#1-notation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Table 1. Symbols used throughout<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Symbol<\/th>\n<th>Shape<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_i$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times 1$<\/math-renderer><\/td>\n<td>One centered sample, written as a column vector<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n$<\/math-renderer><\/td>\n<td>\u2014<\/td>\n<td>The number of samples<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p$<\/math-renderer><\/td>\n<td>\u2014<\/td>\n<td>The number of variables<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$X_c$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n \\times p$<\/math-renderer><\/td>\n<td>The centered data, one sample per row<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times p$<\/math-renderer><\/td>\n<td>The covariance matrix, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C = X_c^\\top X_c \/ (n - 1)$<\/math-renderer>\n<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times 1$<\/math-renderer><\/td>\n<td>A candidate direction, constrained to unit length<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda$<\/math-renderer><\/td>\n<td>\u2014<\/td>\n<td>The Lagrange multiplier, which turns out to be an eigenvalue and a variance<\/td>\n<\/tr>\n<tr>\n<td>\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_j$<\/math-renderer>, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_j$<\/math-renderer>\n<\/td>\n<td>\u2014<\/td>\n<td>The j-th eigenvector and eigenvalue of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer>, ordered so that <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1 \\ge \\lambda_2 \\ge \\cdots$<\/math-renderer>\n<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times k$<\/math-renderer><\/td>\n<td>The loadings matrix, the kept components stacked as columns <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V = [ u_1 \\cdots u_k ]$<\/math-renderer>\n<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k$<\/math-renderer><\/td>\n<td>\u2014<\/td>\n<td>The number of components kept<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Two remarks keep the reading smooth. First, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> is symmetric, because <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(X_c^\\top X_c)^\\top = X_c^\\top X_c$<\/math-renderer>; the derivation leans on that fact twice, once in the gradient and once in the orthogonality argument. Second, the denominator <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n - 1$<\/math-renderer> is the unbiased convention, and nothing below depends on it \u2014 replacing it with <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n$<\/math-renderer> scales every eigenvalue by the same factor and leaves every eigenvector unchanged.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. The Objective<\/h2><a id=\"user-content-2-the-objective\" class=\"anchor\" aria-label=\"Permalink: 2. The Objective\" href=\"#2-the-objective\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The data is a cloud of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n$<\/math-renderer> points in <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p$<\/math-renderer> dimensions, and the question is which single direction keeps the most of its variation.<\/p>\n<p dir=\"auto\">Centering comes first, and it is not a convention but a precondition. Variance is spread about the mean, so the samples must satisfy <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sum_i x_i = 0$<\/math-renderer> before the quantity below deserves the name; skip the centering and the same formula measures the second moment about the origin instead, and the winning direction points at the mean of the cloud rather than along it.<\/p>\n<p dir=\"auto\">A direction is a unit vector <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer>, and the coordinate of a sample along it is the scalar <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top x_i$<\/math-renderer>. The variance of those coordinates is the objective:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\mathrm{Var}(u) = \\frac{1}{n-1} \\sum_{i=1}^{n} \\left( u^\\top x_i \\right)^2\n= u^\\top \\left( \\frac{1}{n-1} \\sum_{i=1}^{n} x_i x_i^\\top \\right) u\n= u^\\top C u\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">The constraint <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top u = 1$<\/math-renderer> is what makes the problem well posed. Doubling <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer> quadruples <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top C u$<\/math-renderer>, so without the constraint the maximum is unbounded and meaningless; the object being chosen is a direction, and fixing the length to one removes everything that is not direction. The problem is therefore:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\max_{u} u^\\top C u \\qquad \\text{subject to} \\qquad u^\\top u = 1\n$$<\/math-renderer><\/p>\n<p dir=\"auto\"><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/ykim2718\/AIML\/blob\/main\/Feature-Engineering\/PCA\/pca-derivation-fig1.png\"><img src=\"https:\/\/ykim.synology.me\/wordpress\/wp-json\/gh-readme\/v1\/asset?user=ykim2718&#038;repo=AIML&#038;branch=main&#038;path=Feature-Engineering\/PCA\/pca-derivation-fig1.png&#038;sig=c18056faeddcbb1a53ecd3d164147373129a68ded58736ff68908156b6c2d7fe\" alt=\"Fig 1\" style=\"max-width: 100%;\"><\/a><\/p>\n<p dir=\"auto\">Fig 1. The problem and its answer for a two-variable cloud with $C = \\bigl[\\begin{smallmatrix} 4 &amp; 2 \\ 2 &amp; 4 \\end{smallmatrix}\\bigr]$. Panel (a) shows the centered cloud with the two directions the derivation finds, drawn with lengths proportional to the spread along them. Panel (b) sweeps the direction <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer> through 180 degrees and plots <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top C u$<\/math-renderer>; the extremes sit exactly at the angles of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_2$<\/math-renderer>, with heights <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1 = 6$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_2 = 2$<\/math-renderer>.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. The Lagrange Condition<\/h2><a id=\"user-content-3-the-lagrange-condition\" class=\"anchor\" aria-label=\"Permalink: 3. The Lagrange Condition\" href=\"#3-the-lagrange-condition\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A constrained maximum is found by folding the constraint into the objective with a multiplier and asking where the combined function is stationary:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nL(u, \\lambda) = u^\\top C u - \\lambda \\left( u^\\top u - 1 \\right)\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Setting the derivative with respect to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda$<\/math-renderer> to zero recovers the constraint. Setting the gradient with respect to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer> to zero gives the condition that matters:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\frac{\\partial L}{\\partial u} = 2 C u - 2 \\lambda u = 0\n\\qquad \\Longrightarrow \\qquad\nC u = \\lambda u\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">The gradient identity <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\partial (u^\\top C u) \/ \\partial u = 2 C u$<\/math-renderer> holds because <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> is symmetric; for a general matrix <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$A$<\/math-renderer> the gradient is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(A + A^\\top) u$<\/math-renderer>, and the factor of two would not collapse.<\/p>\n<p dir=\"auto\">This one line converts the optimization into linear algebra. The candidates for the best direction are not arbitrary vectors to be searched; they are exactly the eigenvectors of the covariance matrix, a finite list that the eigendecomposition produces outright.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">4. The Choice Among Stationary Points<\/h2><a id=\"user-content-4-the-choice-among-stationary-points\" class=\"anchor\" aria-label=\"Permalink: 4. The Choice Among Stationary Points\" href=\"#4-the-choice-among-stationary-points\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C u = \\lambda u$<\/math-renderer> is satisfied by every eigenvector, so it marks all the stationary points and does not by itself name the maximum. One more line decides. Left-multiplying the condition by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top$<\/math-renderer> and using <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top u = 1$<\/math-renderer>:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nu^\\top C u = \\lambda u^\\top u = \\lambda\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">At a stationary point the objective equals its own eigenvalue. Maximizing is therefore nothing more than picking the eigenvector with the largest eigenvalue, and the variance along that first principal direction is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1$<\/math-renderer> itself.<\/p>\n<p dir=\"auto\">Two facts fall out of this line rather than being imposed. The eigenvalue is a variance, which is why <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_j$<\/math-renderer> is called the explained variance and carries the units of the data squared. And sorting the eigenvalues in decreasing order sorts the directions by how much variation each one carries, which is where the ordering of the components comes from. Panel (b) of Fig 1 is this section drawn: as <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u$<\/math-renderer> rotates, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top C u$<\/math-renderer> peaks at the angle of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer> with height <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1$<\/math-renderer> and bottoms out at the angle of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_2$<\/math-renderer> with height <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_2$<\/math-renderer>.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">5. The Later Components<\/h2><a id=\"user-content-5-the-later-components\" class=\"anchor\" aria-label=\"Permalink: 5. The Later Components\" href=\"#5-the-later-components\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The second component answers the same question among the directions not yet used: maximize <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top C u$<\/math-renderer> subject to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top u = 1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u^\\top u_1 = 0$<\/math-renderer>. The second constraint gets its own multiplier:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nL(u, \\lambda, \\varphi) = u^\\top C u - \\lambda \\left( u^\\top u - 1 \\right) - \\varphi u^\\top u_1\n$$<\/math-renderer><\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\frac{\\partial L}{\\partial u} = 2 C u - 2 \\lambda u - \\varphi u_1 = 0\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Left-multiplying by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1^\\top$<\/math-renderer> kills every term but one. <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1^\\top u = 0$<\/math-renderer> by the constraint, and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1^\\top C u = (C u_1)^\\top u = \\lambda_1 u_1^\\top u = 0$<\/math-renderer> by the symmetry of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer>, so the equation collapses to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\varphi = 0$<\/math-renderer> \u2014 the new constraint costs nothing at the optimum \u2014 and the condition is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C u = \\lambda u$<\/math-renderer> again. The second component is once more an eigenvector, the best one still admissible: the eigenvector of the second-largest eigenvalue. Repeating the argument with orthogonality to all earlier picks makes the j-th component the eigenvector of the j-th largest eigenvalue, so the single eigendecomposition delivers the entire ordered basis at once.<\/p>\n<p dir=\"auto\">The orthogonality was not a stylistic preference. Eigenvectors of a symmetric matrix belonging to distinct eigenvalues are orthogonal on their own, so the constraint and the answer agree. When two eigenvalues are equal the picture degrades honestly: any rotation of the pair inside their shared plane satisfies every condition equally well, so the individual directions stop being determined even though the plane they span still is.<\/p>\n<p dir=\"auto\">There is also a fixed budget being divided. The trace of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> is the sum of the individual variable variances and equals <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sum_j \\lambda_j$<\/math-renderer>, so each component claims a share of a total that no choice of basis can change. That total is the denominator of every explained variance ratio.<\/p>\n<p dir=\"auto\">One more object falls out of this section. Stacking the kept components as columns gives the loadings matrix <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V = [ u_1 \\cdots u_k ]$<\/math-renderer> of shape <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times k$<\/math-renderer>, and the two facts in hand \u2014 the unit length imposed in \u00a72 and the orthogonality just proved \u2014 compress into the single statement <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V^\\top V = I_k$<\/math-renderer>. A matrix with that property is called column-wise orthonormal, or semi-orthogonal; the unqualified name orthogonal matrix is reserved for the square case <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k = p$<\/math-renderer>, where <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V^\\top = V^{-1}$<\/math-renderer> and the change of basis is a pure rotation that preserves every length and angle. The reversed product is a different object altogether: <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V V^\\top$<\/math-renderer> is the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times p$<\/math-renderer> projection onto the span of the kept components \u2014 the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$P$<\/math-renderer> that \u00a76 is about to use \u2014 and it cannot equal <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$I_p$<\/math-renderer> while <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k \\lt p$<\/math-renderer>, because its rank is only <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k$<\/math-renderer>. <a href=\"#appendix-c-the-column-wise-orthonormal-matrix\">Appendix C<\/a> lays the two products side by side.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">6. The Reconstruction View<\/h2><a id=\"user-content-6-the-reconstruction-view\" class=\"anchor\" aria-label=\"Permalink: 6. The Reconstruction View\" href=\"#6-the-reconstruction-view\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">PCA is often introduced by a different requirement: choose the k-dimensional subspace that minimizes the average squared distance between each sample and its projection. The two requirements meet in one identity. With <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$P$<\/math-renderer> the projection onto any subspace, each sample splits at a right angle:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\lVert x_i \\rVert^2 = \\lVert P x_i \\rVert^2 + \\lVert x_i - P x_i \\rVert^2\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Summing over the samples and dividing by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n - 1$<\/math-renderer>, exactly as the variance does, turns this into an accounting rule: the total variance equals the variance kept in the subspace plus the mean squared reconstruction error. The left side is fixed by the data, so minimizing the error and maximizing the kept variance are the same act, and both are solved by the eigenvectors already found. Keeping the first <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k$<\/math-renderer> components keeps <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1 + \\cdots + \\lambda_k$<\/math-renderer> and loses exactly <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_{k+1} + \\cdots + \\lambda_p$<\/math-renderer>, which is why the sum of the discarded eigenvalues is not merely correlated with the reconstruction error but equal to it.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">7. The Bridge To The SVD<\/h2><a id=\"user-content-7-the-bridge-to-the-svd\" class=\"anchor\" aria-label=\"Permalink: 7. The Bridge To The SVD\" href=\"#7-the-bridge-to-the-svd\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Implementations rarely form <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer>, and the derivation explains what they do instead. Take the thin SVD of the centered data, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$X_c = U S V^\\top$<\/math-renderer>, with the singular values <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$s_j$<\/math-renderer> on the diagonal of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$S$<\/math-renderer>. Then:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nC = \\frac{X_c^\\top X_c}{n-1} = V \\frac{S^2}{n-1} V^\\top\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">This is already an eigendecomposition: the columns of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V$<\/math-renderer> are the eigenvectors the derivation demands, with eigenvalues <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_j = s_j^2 \/ (n - 1)$<\/math-renderer>, and the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V$<\/math-renderer> the SVD returns is exactly the column-wise orthonormal matrix that \u00a75 built one column at a time. Decomposing <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$X_c$<\/math-renderer> directly therefore returns the same axes without ever building the covariance matrix, and it is the preferred route because forming <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> squares the condition number of the problem before the eigensolver starts.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">8. A Worked Example<\/h2><a id=\"user-content-8-a-worked-example\" class=\"anchor\" aria-label=\"Permalink: 8. A Worked Example\" href=\"#8-a-worked-example\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Every claim above can be checked by hand on three samples of two variables.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\begin{aligned}\n\\text{samples} \\quad &amp; (4, 2),\\ (0, 0),\\ (2, 4) \\\\\n\\text{mean} \\quad &amp; \\mu = (2, 2) \\\\\n\\text{centered} \\quad &amp; x_1 = (2, 0),\\ x_2 = (-2, -2),\\ x_3 = (0, 2)\n\\end{aligned}\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Summed over the three centered samples, the squares of the first variable give 8, the squares of the second give 8, and the cross products give 4, so with <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$n - 1 = 2$<\/math-renderer>:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nC = \\begin{bmatrix} 4 &amp; 2 \\ 2 &amp; 4 \\end{bmatrix}\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">The eigenvalues solve <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\det(C - \\lambda I) = (4 - \\lambda)^2 - 4 = 0$<\/math-renderer>, so <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$4 - \\lambda = \\pm 2$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1 = 6$<\/math-renderer>, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_2 = 2$<\/math-renderer>. Substituting back, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(C - 6I) u = 0$<\/math-renderer> forces equal entries, and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(C - 2I) u = 0$<\/math-renderer> forces opposite ones:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nu_1 = \\frac{1}{\\sqrt{2}} \\begin{bmatrix} 1 \\ 1 \\end{bmatrix}\n\\qquad\\qquad\nu_2 = \\frac{1}{\\sqrt{2}} \\begin{bmatrix} 1 \\ -1 \\end{bmatrix}\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">The two are orthogonal without being asked to be, as \u00a75 promised, and this <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> is the one drawn in Fig 1. The remaining claims each reduce to one line of arithmetic.<\/p>\n<p dir=\"auto\">Table 2. The claims checked against the example<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Claim<\/th>\n<th>Check<\/th>\n<th>Result<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>The variance along <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer> equals <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1$<\/math-renderer> (\u00a74)<\/td>\n<td>The scores <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1^\\top x_i$<\/math-renderer> are <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sqrt{2}, -2\\sqrt{2}, \\sqrt{2}$<\/math-renderer>, with variance <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(2 + 8 + 2) \/ 2$<\/math-renderer>\n<\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$6 = \\lambda_1$<\/math-renderer><\/td>\n<\/tr>\n<tr>\n<td>The total variance equals <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sum \\lambda_j$<\/math-renderer> (\u00a75)<\/td>\n<td>The trace of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$C$<\/math-renderer> is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$4 + 4$<\/math-renderer>\n<\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$8 = 6 + 2$<\/math-renderer><\/td>\n<\/tr>\n<tr>\n<td>The discarded <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda$<\/math-renderer> equals the reconstruction error (\u00a76)<\/td>\n<td>Keeping only <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer>, the residuals are the coordinates along <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_2$<\/math-renderer>, namely <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sqrt{2}, 0, -\\sqrt{2}$<\/math-renderer>, with mean square <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(2 + 0 + 2) \/ 2$<\/math-renderer>\n<\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$2 = \\lambda_2$<\/math-renderer><\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The explained variance ratio of the first component is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$6 \/ 8 = 0.75$<\/math-renderer>, and the example is small enough that all of these numbers survive being recomputed on paper. <a href=\"#appendix-b-the-worked-example-drawn\">Appendix B<\/a> draws the same numbers in both coordinate systems.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The terms below appear in the body without being defined there.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Condition number<\/strong> measures how much a matrix amplifies relative error, so a large one means fewer reliable digits in the result.<\/li>\n<li>\n<strong>Covariance matrix<\/strong> holds the pairwise covariances of the variables, with the variances on its diagonal.<\/li>\n<li>\n<strong>Eigendecomposition<\/strong> writes a symmetric matrix as its eigenvectors scaled by its eigenvalues.<\/li>\n<li>\n<strong>Eigenvector and eigenvalue<\/strong> are a vector that a matrix maps to a multiple of itself, and that multiple.<\/li>\n<li>\n<strong>Gradient<\/strong> is the vector of partial derivatives of a function, which vanishes where the function is flat.<\/li>\n<li>\n<strong>Identity matrix<\/strong> <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$I_k$<\/math-renderer> is the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k \\times k$<\/math-renderer> matrix with ones on the diagonal and zeros elsewhere, which maps every vector to itself.<\/li>\n<li>\n<strong>Lagrange multiplier<\/strong> is the extra variable that folds a constraint into an objective so that a constrained optimum appears as a stationary point.<\/li>\n<li>\n<strong>Orthonormal<\/strong> describes a set of vectors that each have unit length and are mutually orthogonal.<\/li>\n<li>\n<strong>Projection<\/strong> is the component of a vector along a direction or inside a subspace.<\/li>\n<li>\n<strong>Rank<\/strong> is the number of linearly independent directions a matrix spans.<\/li>\n<li>\n<strong>Span<\/strong> is the set of all linear combinations of a set of vectors.<\/li>\n<li>\n<strong>Stationary point<\/strong> is a point where the gradient vanishes, which covers maxima, minima, and saddle points alike.<\/li>\n<li>\n<strong>SVD<\/strong> decomposes a matrix into left singular vectors, singular values, and right singular vectors.<\/li>\n<li>\n<strong>Thin SVD<\/strong> returns only the singular vectors that correspond to non-zero singular values.<\/li>\n<li>\n<strong>Trace<\/strong> is the sum of the diagonal entries of a matrix, which equals the sum of its eigenvalues.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. The Worked Example Drawn<\/h2><a id=\"user-content-appendix-b-the-worked-example-drawn\" class=\"anchor\" aria-label=\"Permalink: Appendix B. The Worked Example Drawn\" href=\"#appendix-b-the-worked-example-drawn\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/ykim2718\/AIML\/blob\/main\/Feature-Engineering\/PCA\/pca-derivation-fig2.png\"><img src=\"https:\/\/ykim.synology.me\/wordpress\/wp-json\/gh-readme\/v1\/asset?user=ykim2718&#038;repo=AIML&#038;branch=main&#038;path=Feature-Engineering\/PCA\/pca-derivation-fig2.png&#038;sig=e666ab58119e3958c94df2039efdc04c7ae476dce9a7e63ae6ea394b0c4f85bf\" alt=\"Fig 2\" style=\"max-width: 100%;\"><\/a><\/p>\n<p dir=\"auto\">Fig 2. The worked example of \u00a78 in pictures. Panel (a) shows the three samples, their mean <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\mu = (2, 2)$<\/math-renderer>, and the centering that moves each sample by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$-\\mu$<\/math-renderer> so the cloud sits about the origin. Panel (b) shows the centered samples with the axis <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer> and the direction <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_2$<\/math-renderer>; the open circles are the projections onto <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer>, whose positions along the axis are the scores <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\sqrt{2}, -2\\sqrt{2}, \\sqrt{2}$<\/math-renderer>, and the dashed segments are the residuals, whose average square <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(2 + 0 + 2) \/ 2 = 2$<\/math-renderer> equals the discarded <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_2$<\/math-renderer>.<\/p>\n<p dir=\"auto\">Every number in Table 2 has a visible counterpart here. The scores are where the open circles sit along <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer>, the spread of those circles is the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_1 = 6$<\/math-renderer> the derivation maximized, and the dashed segments are what the one-component reconstruction gives up. Two details reward a second look. <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_2$<\/math-renderer> lies on the axis already, so keeping one component reconstructs it exactly. And <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_3$<\/math-renderer> land on the same projected point \u2014 two different samples that the one-component summary can no longer tell apart, which is what losing <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$\\lambda_2$<\/math-renderer> means in concrete terms.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix C. The Column-wise Orthonormal Matrix<\/h2><a id=\"user-content-appendix-c-the-column-wise-orthonormal-matrix\" class=\"anchor\" aria-label=\"Permalink: Appendix C. The Column-wise Orthonormal Matrix\" href=\"#appendix-c-the-column-wise-orthonormal-matrix\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The components of \u00a75 are usually handled not one at a time but stacked into a single matrix, one component per column:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nV =\n\\begin{bmatrix}\n\\vert &amp; \\vert &amp; &amp; \\vert \\\\\nu_1 &amp; u_2 &amp; \\cdots &amp; u_k \\\\\n\\vert &amp; \\vert &amp; &amp; \\vert\n\\end{bmatrix}\n\\in \\mathbb{R}^{ p \\times k}\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Every entry of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V^\\top V$<\/math-renderer> is a product of one column with another, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(V^\\top V)_{ij} = u_i^\\top u_j$<\/math-renderer>, so the unit lengths of \u00a72 fill the diagonal with ones and the orthogonality of \u00a75 fills everything off the diagonal with zeros. No such argument exists for the rows, and the two products come out asymmetric:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\n\\underbrace{ V^\\top V = I_k }_{\\textbf{column test:} \\text{ always passes}}\n\\qquad\\qquad\n\\underbrace{ V V^\\top \\neq I_p }_{\\textbf{row test:} \\text{ fails whenever } k \\lt p}\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">The asymmetry is why the naming is column-wise. A rectangular <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V$<\/math-renderer> that passes only the column test is called a column-wise orthonormal matrix, or a semi-orthogonal matrix; the unqualified name orthogonal matrix is reserved for the square case <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k = p$<\/math-renderer>, where both tests pass at once and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V^\\top = V^{-1}$<\/math-renderer>. The failed row test is not a defect but the point of the truncation: <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V V^\\top$<\/math-renderer> is the projection onto the span of the kept components \u2014 the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$P$<\/math-renderer> of \u00a76 \u2014 and a projection that changed nothing would have compressed nothing.<\/p>\n<p dir=\"auto\">Table 3. The two products of the loadings matrix<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Product<\/th>\n<th>Shape<\/th>\n<th>Value<\/th>\n<th>Reading<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V^\\top V$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k \\times k$<\/math-renderer><\/td>\n<td>\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$I_k$<\/math-renderer> always<\/td>\n<td>The columns are unit length and mutually orthogonal<\/td>\n<\/tr>\n<tr>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V V^\\top$<\/math-renderer><\/td>\n<td><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$p \\times p$<\/math-renderer><\/td>\n<td>\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$I_p$<\/math-renderer> only when <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k = p$<\/math-renderer>\n<\/td>\n<td>The projection onto the span of the kept components, with rank <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$k$<\/math-renderer>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The worked example of \u00a78 shows both cases in the smallest possible numbers. Keeping both components makes <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V$<\/math-renderer> square, and both tests pass:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nV = \\frac{1}{\\sqrt{2}} \\begin{bmatrix} 1 &amp; 1 \\ 1 &amp; -1 \\end{bmatrix}\n\\qquad\nV^\\top V = I_2\n\\qquad\nV V^\\top = I_2\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Keeping only <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$u_1$<\/math-renderer> leaves the column test intact while the row test produces the projection that drew the open circles of Fig 2:<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$$\nV = \\frac{1}{\\sqrt{2}} \\begin{bmatrix} 1 \\ 1 \\end{bmatrix}\n\\qquad\nV^\\top V = \\begin{bmatrix} 1 \\end{bmatrix}\n\\qquad\nV V^\\top = \\frac{1}{2} \\begin{bmatrix} 1 &amp; 1 \\ 1 &amp; 1 \\end{bmatrix} \\neq I_2\n$$<\/math-renderer><\/p>\n<p dir=\"auto\">Applying that last <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$V V^\\top$<\/math-renderer> to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_1 = (2, 0)$<\/math-renderer> gives <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$(1, 1)$<\/math-renderer>, which is exactly where the dashed segment of Fig 2 lands \u2014 the matrix that fails the row test is the same map that sent <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"c455855e6ce0d85a966bd70748052bed\">$x_3$<\/math-renderer> to their shared projection.<\/p>\n<\/article><\/div><\/div><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>Not how to compute PCA but why its answer is right. One constrained maximization with a Lagrange multiplier gives Cu = \u03bbu, so the axes must be eigenvectors of the covariance matrix. The ordering, the orthogonality, and minimum reconstruction error all fall out of that line unasked.<\/p>\n","protected":false},"author":4,"featured_media":6767,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","fifu_image_url":"","fifu_image_alt":"","iawp_total_views":4,"footnotes":""},"categories":[56,373],"tags":[386,385],"class_list":["post-6766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-science-slug","category-feature-engineering-slug","tag-github-hosted","tag-pca"],"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":0,"sum_votes":0},"jetpack_featured_media_url":"https:\/\/ykim.synology.me\/wordpress\/wp-content\/uploads\/2026\/08\/apex-ice-arena-rink.jpg","_links":{"self":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/comments?post=6766"}],"version-history":[{"count":3,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6766\/revisions"}],"predecessor-version":[{"id":7466,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6766\/revisions\/7466"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media\/6767"}],"wp:attachment":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media?parent=6766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/categories?post=6766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/tags?post=6766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}