Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 2 of 3

Reconstruct observations and account for lost variation

Prove the projection loss and compare mean reconstruction with new-data performance.

Loading your saved responses…

Try

Keep the four worked observations (13,21), (11,23), (9,17), (7,19). Their mean is μ=(10,20), and their first loading is v=(1,1)/√2. Suppose storage permits one score per observation instead of two centered coordinates. What can we reconstruct, and what information did we discard?

For the first observation, the centered row is (3,1) and its score is 2√2. Multiplying score by loading gives (2,2). This is still a centered reconstruction. Add the mean to obtain the original-unit approximation (12,22). Its residual is (1,−1), with squared length 2. Reporting (2,2) as an approximation to (13,21) would confuse coordinate systems.

Return to centering and scores for the live data table. This lesson proves what that table’s reconstruction error measures. It does not infer a response variable or fit a supervised regression.

Predict

The covariance eigenvalues are 32/3 and 8/3. Predict whether the discarded eigenvalue 8/3 equals the total squared reconstruction error. There are four observations and covariance used divisor 3. A variance is a normalized sum, so the total discarded sum is 3(8/3)=8.

Predict also whether keeping both component scores gives exact reconstruction. Two orthonormal coordinates represent the whole plane; keeping both is a change of basis, not compression. Perfect reconstruction in that case does not establish that either coordinate can be removed harmlessly.

Experiment

Use the worked-data preset in the PCA workbench, with covariance mode. Before inspecting its restored table, calculate all four reconstructed rows and residuals. Then change one observation and explain why the mean and all reconstructed rows may change, even though only one row was edited.

OriginalRestored rank-one reconstructionResidualSquared residual
(13,21)(12,22)(1,−1)2
(11,23)(12,22)(−1,1)2
(9,17)(8,18)(1,−1)2
(7,19)(8,18)(−1,1)2

Total centered squared length is 40. The retained component accounts for 32 and residuals for 8, so the explained-variance fraction is 32/40=4/5. This is a fraction of training variation in the chosen coordinates. It is not prediction accuracy, the probability a component is correct, or the fraction of a scientific phenomenon explained causally.

The workbench draws perpendicular projections in its analyzed coordinate system. In correlation mode, that is the standardized system, while its reconstruction table restores original units. Keep those two displays distinct when comparing losses.

Understand

A direct error proof

Write a centered row as a column x for this calculation. For a unit vector v, its projection is xhat=(vᵀx)v. The residual x−xhat is perpendicular to v because vᵀ(x−xhat)=vᵀx−vᵀx=0. The Pythagorean identity gives

||x−xhat||² = ||x||² − (vᵀx)².

Sum over the n rows of centered matrix X. The squared Frobenius norm, written ||X||F², means the sum of squares of all entries. Thus

||X−Xvvᵀ||F² = ||X||F² − ||Xv||².

The first term is fixed by the data. Minimizing residual loss is therefore exactly maximizing score variation. The preceding lesson proved that a top eigenvector of C=XᵀX/(n−1) does this. Since trace(C), the sum of its diagonal entries, equals both total sample variance and Σ λ_j, the minimum one-component loss is

(n−1)(λ₂+⋯+λ_d).

This establishes a training least-squares optimum under a specific Euclidean metric. It makes no probabilistic assumptions about the rows.

Why the fitted affine line can pass through the mean

An arbitrary affine line can be written a+span(v). Its squared residual sum is Σ||(I−vvᵀ)(z_i−a)||² for original observations z_i. Write z_i−a=(z_i−μ)+(μ−a). The cross terms sum to zero because Σ(z_i−μ)=0. The loss is the centered projection loss plus n||(I−vvᵀ)(μ−a)||². The latter term is nonnegative and vanishes when the line passes through μ. Thus using the mean is part of the affine optimum, not an aesthetic choice. Moving a along the same line does not change that line.

More than one retained component

For an integer k with 1≤k≤d and k orthonormal loadings arranged as columns of V, projection is XVVᵀ. The same orthogonal decomposition gives loss ||X||F²−||XV||F². In a covariance eigenbasis q_j, put w_j=||Vᵀq_j||². Orthogonal projection implies 0≤w_j≤1, and summing squared coordinates of the k unit columns gives Σw_j=k. Therefore

Σ λ_j w_j ≤ λ₁+⋯+λ_k.

For clarity, subtract the left side from the right: the deficit is Σ over j≤k of λ_j(1−w_j) minus Σ over j>k of λ_j w_j. Bound the first weights below by λ_k and the second above by λ_k; the remaining difference is zero because Σ over j≤k of (1−w_j)=Σ over j>k of w_j. Choosing the first k eigenvectors attains the bound. The optimal loss is (n−1)Σ over j>k of λ_j. For k=d it is zero. The SVD and low-rank approximation lesson supplies the related general matrix theorem; the argument here connects it to centered statistical data.

Freeze preprocessing for validation

A learned transform includes its training mean and, if used, training standard deviations. Evaluate new observations using those stored quantities and loadings. Re-centering or refitting on the validation observations changes the transform being evaluated. A later revised model may be useful, but must be disclosed and evaluated on another appropriate record.

Apply

Train covariance PCA on (−2,0), (0,0), (2,0). Freeze the transform. Then inspect new observations (0,3), (0,−3). Compute the training fraction and validation loss; compare with a colleague who chooses a new axis after seeing the new observations.

Check training and new-data evidence separately

The training mean is zero and covariance is diag(4,0). The x-axis captures all nonzero training variation, so fraction=1 and training loss=0. The frozen projection sends both new points to zero. Their squared residuals are 9 and 9, giving validation loss 18. Fitting the new points alone instead chooses the y-axis and yields zero error on those same points. That is not the validation performance of the original transform. Two synthetic observations do not estimate a reliable population performance distribution; they expose the logical distinction between fit and evaluation.

Continue

In scaling and degenerate directions, decide which metric the reconstruction should optimize and what to report when the data do not identify a unique direction. Retain both a direct residual calculation and an eigenvalue-based check. Agreement is numerical evidence for your calculation, not verification of the collection process or the scientific interpretation.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

For rows (2,0),(−2,0),(0,1),(0,−1), find the covariance PCA first axis, rank-one reconstructions, total squared error and explained fraction. Verify the loss directly and from the omitted eigenvalue.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

For centered X with n observations and a unit vector v, prove ||X−Xvvᵀ||F²=tr(XᵀX)−||Xv||². Deduce rank-one PCA optimality and the loss (n−1)Σj≥2 λj. Define the norm and explain the affine mean restoration.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

A sample of seven rows has covariance eigenvalues 9 and 2. A report calls 2 the total rank-one squared reconstruction error and calls 9/2 its explained fraction. Repair both claims and explain which quantities have units.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Let V be a square orthogonal loading matrix for centered X. Prove exact reconstruction from all scores XV and show how truncating to k orthonormal columns changes the residual formula. Is two-component reconstruction in the two-variable tool a test of useful compression?

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Train covariance PCA on (−2,0),(0,0),(2,0). Freeze mean and first axis, then evaluate new rows (0,3),(0,−3). Compute training fraction and validation squared loss. A colleague refits on the new rows before reporting their loss. Explain the change.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Training mean is μ=(3,−1) and frozen loading v=(1,0). Reconstruct a new observation (5,4), giving its score, restored point and squared residual. Explain why subtracting the validation sample mean instead would alter the deployed transformation.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.