ECE571 / Week 10 · Dimensionality reduction

Week 10 · Dimensionality reduction

PCA, kernel PCA and ICA

High-dimensional data often lives near a much smaller subspace. PCA finds that subspace by rotating the data onto the directions where it varies most, and it all comes down to one eigenvalue problem.

~40 min read 10 practice questions + 2 problems Reading: Géron Ch. 8 (PCA, Kernel PCA)
The big picture

Week 9's clustering was one kind of unsupervised learning; this week is the other big one, dimensionality reduction. Real datasets have thousands or millions of features (pixels, words, sensor readings), but the features are strongly correlated, so the data really lives near a much lower-dimensional subspace. Principal component analysis (PCA) finds that subspace. It picks the direction along which the centered data has the largest variance, then the next one at right angles to it, and so on. Those directions turn out to be the eigenvectors of the covariance matrix, and each eigenvalue says how much variance its direction holds. Keep the top few and you have a compressed, denoised, faster-to-learn-from version of the data. Kernel PCA uses week 5's kernel trick to find curved structure, and ICA looks for statistically independent directions instead of high-variance ones. The professor opens by calling PCA "one of the important algorithms you should know" (00:10).

After this you can
Section 1

Why reduce dimensions?

Lecture 00:00–05:28Slides 1–5Géron Ch. 8 intro, "The Curse of Dimensionality"

The slides' examples of "big and high-dimensional" data:

  • Documents: one feature per word (thousands) or per word pair (millions).
  • Netflix ratings: a 480,189 users × 17,770 movies matrix. Just loading it into memory is a problem.
  • MEG brain imaging: 120 sensor locations × 500 time points × 20 subjects, with strong dependence between neighboring locations and times.
  • Images: a 100 × 100 color image is already numbers.

In each case the features are highly redundant, so a much smaller set of numbers could describe each example almost as well. Learning that smaller representation helps with (slide 5):

GoalWhy fewer dimensions help
VisualizationWe can only plot 2-D or 3-D. Project down and look for clusters.
ResourcesLess time, memory and communication to store and process.
GeneralizationFewer inputs means a simpler model with less capacity to overfit (week 2).
Noise removalSmall-variance directions are often mostly noise; dropping them cleans the data.
PreprocessingFeed the reduced data to a classifier or to k-means (week 9), faster and often better.
Back to week 4

Week 4 ended with the curse of dimensionality: in high dimensions, nearest neighbors are nearly as far away as everything else, and the fix promised was "PCA in week 10". This is it. If 1,000 features really vary along only 20 directions, k-NN on the 20 PCA coordinates measures distances in the space where the data actually lives.

Quick check: why can dropping dimensions improve test accuracy, not just speed?

A model with fewer inputs has less capacity to fit noise, so it overfits less. And if the dropped low-variance directions were mostly noise, the remaining features are cleaner. Both effects can lower test error even though some information is thrown away.

Section 2

The idea: keep the directions with the most variance

Lecture 05:28–09:58Slides 6–8Géron Ch. 8, "Preserving the Variance", "Principal Components"

Look at a 2-D cloud that is long in one direction and thin in the other. Both original coordinates vary, so you seem to need both. But if you rotate your axes to line up with the cloud, almost all the spread is along one new axis. Describing each point by its position along that axis loses very little. Slide 7 puts it this way: the data is "intrinsically lower dimensional than the dimension of the ambient space".

PCA formalizes this. It is an orthogonal projection of the data onto a (possibly lower-dimensional) subspace chosen so that the variance of the projected data is as large as possible (slide 6).

  • The first principal component (PC1) is the direction of greatest variance.
  • The second (PC2) is the direction of greatest remaining variance, at a right angle to PC1.
  • And so on: in dimensions you get at most mutually orthogonal PCs (21:50).
x₁x₂ PC1 PC2
The PCs are the cloud's own axes. 60 points sampled around a tilted ellipse. Arrows start at the mean (hollow dot) and have length 2√λ (two standard deviations along that direction). This sample's eigenvalues are λ₁ = 7.82 and λ₂ = 0.76, so PC1 alone carries 91% of the variance, and describing each point by one number (its PC1 coordinate) loses little.
onto PC1 (16°) variance of projections = 7.8 onto PC2 (106°) variance of projections = 0.8
Same points, two projection lines. Dropping each point straight onto the PC1 line (left) keeps them spread out: variance 7.8. Projecting onto the perpendicular line (right) squashes them together: variance 0.8. PCA picks the line that keeps the points most spread out, because spread is what distinguishes one point from another.

Slide 7 also notes that PCA follows rotations: rotate the data and the PCs rotate with it, so the same single coordinate stays important. That's because PCA is a purely linear operation (07:00). In 3-D, the same idea finds the plane a cloud lies near and projects onto it (slide 8, 09:21).

Quick check: data in 5-D lies exactly on a 2-D plane through the mean. How many PCs have nonzero variance?

Two. The other three directions are perpendicular to the plane, the data doesn't vary along them at all, and their eigenvalues are exactly 0. Slide 17: zero eigenvalues mean the data lies exactly on a linear subspace.

Section 3

The first PC is an eigenvector of the covariance matrix

Lecture 09:58–13:22, 15:36–18:12Slides 9, 11, 12, 23Bishop §12.1.1

Setup. We have data points . The slides stack them as columns of a matrix .

Step 0: center the data. Subtract the sample mean from every point. From now on means the centered point, so .

Flagged in lecture · 12:27–13:15

"One thing we need to remember is, for the PCA, what do we need to do before doing an operation for PCA is we try to zero-mean the data … remember, you have to zero-mean, otherwise the PC is wrong."

Why: without centering, measures spread around the origin, not around the mean. If the cloud sits far from the origin, the "best" direction just points from the origin toward the cloud. Géron gives the same warning: scikit-learn's PCA centers for you; if you code it yourself, you must do it.

Step 1: projecting onto a direction. Take a unit vector (). The scalar projection of onto is , the point's coordinate along . The projected point itself, back in , is .

Step 2: the objective. Because the data is centered, the projections have mean 0, so their variance is the mean of their squares:

the sample covariance matrix (entry is the covariance of features and )
without it, the variance could be made infinite by making long

Step 3: Lagrange multiplier. Fold the constraint into the objective with a multiplier and set the gradient to zero:

So the best direction must be an eigenvector of . Which one? Multiply both sides by :

The variance captured along an eigenvector is its eigenvalue. To maximize it, take the eigenvector with the largest eigenvalue. That's PC1. Slide 12 calls the eigenvalue "the amount of energy along that dimension".

Heads up: slides 11, 12, 14–16 drop the 1/n

Slides 11 and 14–16 write . The right side is missing the ; it should be (slide 23 gets it right). Slides 12, 13 and 24 then call itself the "sample correlation/covariance matrix". Strictly, is the scatter matrix, times the covariance; a correlation matrix would further divide by each feature's standard deviation.

What this changes: and have the same eigenvectors, and the eigenvalues differ by the factor . The PCs and the explained-variance ratios are identical; only the eigenvalues' absolute size changes. In the worked example below, has eigenvalues 44 and 4, while has 11 and 1.

Heads up: lecture 15:36 and 28:10, "linear system"

The lecture calls "a classic linear system", and later says PCA has no local optima "because this is solving a linear system". It is an eigenvalue problem, not a linear system : it only has nonzero solutions for special values of . The reason there are no local-optimum worries is that an eigendecomposition gives the exact global answer directly, with no iterative search from a random start.

Quick check: . What are PC1 and the variance along it?

is diagonal, so its eigenvectors are the coordinate axes, with eigenvalues 4 and 1. PC1 with variance 4. The features are already uncorrelated, so PCA has nothing to rotate.

Section 4

The other PCs

Lecture 13:22–15:36, 16:42–19:56Slides 10, 12, 13Géron Ch. 8, "Principal Components"

The iterative definition (slide 10). After finding PC1 , remove it from every point. The residual is what's left after subtracting the projection:

PC2 is the unit vector that maximizes the variance of the residuals, . Then take residuals again and repeat for PC3, and so on. The professor points out that doing this one direction at a time is slow (15:02).

The one-shot answer (slide 12). You don't actually need the loop. Do one eigendecomposition of , sort the eigenvalues , and the matching eigenvectors are PC1, PC2, …, PC in order. Because is symmetric, its eigenvectors are automatically orthogonal, which is exactly the constraint the iterative definition imposes.

Projecting. Put the first PCs as columns of a matrix . Each point's new coordinates are

the "transformed representation" or coefficients of point (slide 17): numbers instead of
the projection matrix; its columns are orthonormal, so

Slide 13 sums up the geometry: PCA is centering followed by a rotation (and, if you drop components, a projection). Two facts follow:

  • The new features are uncorrelated. The covariance of the 's is : zero off the diagonal.
  • Total variance is preserved by the full rotation: = the sum of the original features' variances.
Cross-check with the textbook: rows vs columns

The slides store points as columns ( is , projection ). Géron and scikit-learn store points as rows ( is , projection with ). Same math, transposed. Géron also warns that the sign of each PC is arbitrary: is just as good an eigenvector, and different solvers may flip it.

Quick check: why is the second PC automatically perpendicular to the first?

The covariance matrix is symmetric, and eigenvectors of a symmetric matrix with different eigenvalues are orthogonal. In the iterative view, the residuals have no component along at all, so the best direction for them has none either.

Section 5

Maximum variance = minimum reconstruction error

Lecture 19:56–21:50Slides 14–16, 28Bishop §12.1.2; Géron Ch. 8, "Preserving the Variance"

Slide 28 ("What you should know") lists both viewpoints, so know both and why they agree.

  • Maximum variance: choose to maximize .
  • Minimum reconstruction error: choose so that replacing each point by its projection loses as little as possible:

Why they're the same: Pythagoras (slide 16). The residual is perpendicular to , so the point, its projection and its residual form a right triangle:

v x = (4, 0) ‖x‖² = 16 (vᵀx)² = 14.4 residual² = 1.6
Every point splits into projection² + residual² = a fixed total. Here x = (4, 0) is projected onto PC1 of the worked example, v = (3, 1)/√10: 14.4 + 1.6 = 16. Turning v changes how the 16 is shared, never the 16, so making the blue side long is the same as making the orange side short.

Average over all points: the left side is a constant (the total variance), so more projected variance means exactly that much less reconstruction error. The figure below sweeps every direction for the worked example's data.

-90° -45° 0° 45° 90° 0 4 8 12 angle θ of the unit vector v max variance 11 at 18.4° min error 1 variance error
The two curves are mirror images: they add up to 12 at every angle. For the worked example's covariance (total variance 10 + 2 = 12), the variance along a unit vector at angle θ peaks at λ₁ = 11 at θ = 18.4° (the direction (3, 1)), exactly where the mean squared reconstruction error bottoms out at λ₂ = 1. The worst direction, at 108.4° (shown here as −71.6°), is PC2.

With components the same argument gives a useful formula: the mean squared reconstruction error equals the sum of the discarded eigenvalues, .

Quick check: eigenvalues are 6, 3, 1. You keep 2 PCs. What is the mean squared reconstruction error?

The sum of what you dropped: . That's 10% of the total variance of 10.

Section 6

Worked example: PCA by hand

Builds on slides 11–17Géron Ch. 8, "Projecting Down to d Dimensions"

The lecture never runs PCA on actual numbers, so here's a complete one. Data: four points in 2-D,

  1. Center. The mean is , . Subtracting it gives , , , .
  2. Covariance (with , as on the slides). Sums over the centered points: , , . Divide by :
  3. Eigenvalues. Solve : So , . Check: they sum to the trace .
  4. Eigenvectors. For : the first row of says , so . Normalize: , about , at 18.4° from the -axis. PC2 is perpendicular: .
  5. Project onto PC1. , which is on the centered coordinates: , , , . Their mean square is . ✓
  6. Reconstruct. gives , , , . Squared errors: , , , ; mean . ✓
  7. Explained variance ratio. PC1 keeps of the variance; PC2 holds the other .
0 2 4 6 8 10 2 4 6 PC1 (1,1) (3,3) (7,5) (9,3) mean (5,3)
PCA replaces each point by the closest point on one line. The line through the mean (5, 3) in direction (3, 1) is PC1. Hollow dots are the 1-D reconstructions; the dashed segments are the residuals, all perpendicular to the line. Their mean squared length, 1.0, is the smallest any line can achieve, and it equals λ₂.
PointCenteredReconstruction‖x‖² (centered)z²Residual²
(1, 1)(−4, −2)−4.427(0.8, 1.6)2019.60.4
(3, 3)(−2, 0)−1.897(3.2, 2.4)43.60.4
(7, 5)(2, 2)2.530(7.4, 3.8)86.41.6
(9, 3)(4, 0)3.795(8.6, 4.2)1614.41.6
Mean01211 = λ₁1 = λ₂

Each row obeys Pythagoras (‖x‖² = z² + residual²), and the bottom row is the whole story of Section 5: 12 = 11 + 1.

Cross-check: 1/n vs 1/(n−1)

The slides and Bishop divide by . Géron's scikit-learn PCA reports explained_variance_ with (the unbiased estimate): here 14.67 and 1.33 instead of 11 and 1. The PCs and the ratio explained_variance_ratio_ = (0.917, 0.083) are the same either way. Running scikit-learn on these four points also returns PC2 as , the negative of ours, which is the arbitrary sign Géron warns about.

Quick check: what is the PC1 coordinate of a new point (8, 4)?

Center with the training mean first: . Then

(This point lies exactly on the PC1 line, so its reconstruction error is 0.)

Section 7

Reducing, reconstructing, and choosing k

Lecture 18:12–19:56, 21:50–25:40Slides 13, 17, 18Géron Ch. 8, "Explained Variance Ratio", "Choosing the Right Number of Dimensions", "PCA for Compression"

Reduce. Keep the top PCs and represent each point by : numbers instead of . If some eigenvalues are exactly 0, keeping the nonzero ones loses nothing at all (slide 17). In practice noise makes every eigenvalue slightly positive, so we drop the small ones and accept a small loss (slide 18).

Reconstruct (decompress). Map back with the transpose and add the mean (Géron Eq. 8-3):

Choose k. Each PC's explained variance ratio is its eigenvalue over the total, and the cumulative version adds them up:

The cumulative curve always increases and ends at 1. The rule from the lecture (23:06): pick a threshold such as 90% or 95% of the "energy", draw a horizontal line there, and keep the smallest where the curve crosses it. The threshold is your choice; 99% is fine too, it just keeps more components.

0% 25% 50% 75% 100% 1 2 3 4 5 6 7 8 9 10 number of components k 95% k = 6 cumulative each PC
Keep components until the cumulative curve crosses the threshold. Ten eigenvalues 4, 2.5, 1.5, 0.8, 0.5, 0.3, 0.2, 0.1, 0.06, 0.04 (total 10). Bars are each PC's share (slide 18's "scree plot"); the line is the running total. It reaches 93% at k = 5 and 96% at k = 6, so a 95% threshold keeps 6 of 10 dimensions (90% would keep 5).
k12345678910
λ4.02.51.50.80.50.30.20.10.060.04
cumulative40%65%80%88%93%96%98%99%99.6%100%

Géron's version of the same rule: np.argmax(np.cumsum(pca.explained_variance_ratio_) >= 0.95) + 1, or simply PCA(n_components=0.95). On MNIST, 95% of the variance needs about 154 of 784 dimensions, under 20% of the original size, and the decompressed digits still look right. Other ways to pick : look for an elbow where the curve flattens, use or 3 for plots, or treat as a hyperparameter and cross-validate the downstream model.

Quick check: eigenvalues 5, 3, 1, 1. Smallest k that keeps at least 90%?

Total 10. Cumulative: 50%, 80%, 90%, 100%. The curve reaches 90% at .

Section 8

Eigenfaces, clustering, and PCA's pros and cons

Lecture 25:40–29:08Slides 19–21

Eigenfaces (slide 19). Flatten each face image into one long vector (one entry per pixel), stack thousands of them, and run PCA. Each PC is itself a vector of pixel values, so it can be displayed as an image: a ghostly "eigenface". With 15 PCs learned from 7,562 images, every face is approximately the mean face plus a weighted sum of the 15 eigenfaces, so it can be stored and compared as just 15 numbers instead of thousands of pixels. (The slide says "linear combination of the rest"; the reconstruction formula above adds the mean face too.)

Before clustering (slide 20). Run PCA first, then k-means (week 9) on the reduced data. The slide's experiments report a k-means cost increase under 5% with a 10× to 100× speedup.

Strengths (slide 21)Weaknesses (slide 21)
An eigenvector method: one exact computation.Only second-order statistics: it sees only the covariance . Structure that doesn't show up in variances and covariances is invisible to it.
No hyperparameters to tune except the number of components (like k in k-means).Only linear projections: data on a curved surface (a ring, a Swiss roll) can't be flattened by a rotation.
No local optima: unlike k-means or EM, the answer doesn't depend on a random start.Sensitive to feature scale: a feature measured in big units dominates the variance, so standardize first when units differ.

The two weaknesses on the slide motivate the last two methods of the lecture: kernel PCA removes the linearity limit, and ICA goes beyond second-order statistics.

Quick check: why might you standardize features before PCA?

PCA maximizes variance, and variance depends on units. Income in dollars has a far larger variance than age in years, so PC1 would just be "income" regardless of structure. Standardizing puts features on an equal footing (it amounts to doing PCA on the correlation matrix).

Section 9

Computing the PCs: eigendecomposition, SVD, power method

Lecture 39:32–43:54Slides 29–33Géron Ch. 8, "Principal Components", "Randomized PCA", "Incremental PCA"

Eigendecomposition (slide 31). Any symmetric matrix, such as , factors as

, orthonormal; its columns are the eigenvectors (the PCs)
diagonal, real eigenvalues

SVD (slides 32–33). You can skip forming and factor the data matrix directly. With as (columns are points), the slides write

, orthonormal columns
diagonal, singular values
: the right singular vectors of are the PCs

Comparing with : the eigenvalues of are (and the covariance's are ). The rows of are each point's coordinates along the PCs (slide 33). This is how scikit-learn computes PCA (Géron: U, s, Vt = np.linalg.svd(X_centered)), because it's numerically more accurate than forming .

Worked example, via SVD

For the centered 4 × 2 data from Section 6, the singular values are and . Then are the eigenvalues of , and are the covariance eigenvalues from before. The first right singular vector is , and the first column of is : the same PC1 coordinates.

Flagged in lecture · 43:15–43:46, but the claim is wrong

The professor says: "the singular value can be negative … so smaller sigma here probably gives you a larger eigenvalue. Remember this case. You cannot use singular value to select the PCs. You have to use eigenvalue or S squared."

Correct version: singular values are never negative. By definition , sorted largest first (any sign is absorbed into or ). Since squaring is increasing on , ranking PCs by or by gives the same order. What is true and worth remembering: variance is , not . For explained-variance ratios, use ; with that's , not .

Power method (slide 30). When is huge and you only need the top one or two PCs, iterate:

Each multiplication stretches the component by and the others by smaller factors, so after normalizing, swings toward ; the leftover error shrinks roughly by per step. Computing costs per iteration without ever forming the matrix, which is why the lecture calls it linear-cost (39:32). Slide 30's claim: after iterations, with high probability . For the next PC, subtract each point's component (the residuals of Section 4) and repeat.

IterationAngle to (target 44)
0(1, 0)18.4°40
1(0.958, 0.287)1.74°43.963
2(0.950, 0.314)0.16°43.9997
3(0.9488, 0.3160)0.014°43.999997

(Worked example, , : the angle shrinks about elevenfold per step.)

At scale (Géron). Randomized PCA (svd_solver="randomized") approximates the top PCs much faster than a full SVD when . Incremental PCA (IncrementalPCA with partial_fit) processes mini-batches, for datasets that don't fit in memory, which was the Netflix-matrix worry from the start of the lecture.

Quick check: when does the power method converge slowly?

When is close to . The error shrinks by about per step, so eigenvalues 10 and 9.5 need many iterations while 10 and 1 need just a few. (If they're equal, PC1 isn't even unique.)

Section 10

Kernel PCA

Lecture 29:08–38:44Slides 22–28Géron Ch. 8, "Kernel PCA", "Selecting a Kernel and Tuning Hyperparameters"; Bishop §12.3

Linear PCA can only rotate and project. If the data lies near a curve or a curved surface, no flat subspace fits it well. Kernel PCA borrows week 5's idea: map each point into a high-dimensional feature space with , run ordinary PCA there, and use a kernel so you never compute explicitly (slide 22).

The problem: PCA as written uses the matrix , which isn't made of dot products between points. The kernel trick needs the matrix of dot products, (slide 24). The derivation (slides 25–26) rewrites PCA so only appears.

  1. The PC lies in the span of the data. Any component of perpendicular to all data points contributes nothing to the variance but uses up length, so the best is a combination of the points: This is the same move as the SVM dual's (30:14).
  2. Substitute into :
  3. Left-multiply by : Now the data appears only through the inner-product matrix , whose entry is .
  4. Swap in a kernel. Replace by with , and cancel one from both sides: So kernel PCA is an eigendecomposition of the kernel matrix.
  5. Project a point (slide 27). Its coordinate along this kernel PC is which needs only kernel evaluations against the training points.
Heads up: slide 26 and lecture 33:24, cancelling K and normalizing α

The lecture justifies cancelling by assuming is full rank. That's not needed: Bishop §12.3 shows the two equations differ only by eigenvectors with zero eigenvalue, which don't affect any projection.

Also missing from the slides: the scale of . We need in feature space, and . So rescale each eigenvector to , not 1. Otherwise the projections in step 5 come out wrongly scaled.

Heads up: lecture 38:20, kernel PCA does need centering

The lecture says "for the kernel PCA you may not need a zero mean, because everything is defined on kernels … zero mean is only useful for the linear case." That's wrong. The derivation assumed the mapped points have zero mean, exactly as linear PCA assumed centered . You can't subtract the mean of directly, but you can center the kernel matrix (Bishop §12.3):

and then eigendecompose . scikit-learn's KernelPCA does this automatically. Skipping it has a visible effect: on the ring data below (80 points, RBF, γ = 5), the top eigenvector of the uncentered has every entry the same sign and an eigenvalue (0.209) far above the rest (0.113, 0.101). It just encodes "where the data is", the same failure as uncentered linear PCA from Section 3.

original 2-D data x₁ horizontal, x₂ vertical kernel PCA (RBF, γ = 5) kernel PC1 horizontal, PC2 vertical
Kernel PCA can untangle what no rotation can. Left: two concentric rings (80 points). Linear PCA would only rotate this picture. Right: the first two kernel PCs with an RBF kernel (γ = 5, centered). Along kernel PC1 alone, every outer-ring point (squares, −0.38 to −0.28) falls below every inner-ring point (circles, 0.10 to 0.53), so one threshold (dashed) separates them. The colors are only for you: kernel PCA never sees the labels.

Slide 27 shows the same idea with three clusters: each kernel PC, plotted as a function over the plane, lights up a different cluster or splits one.

Linear PCAKernel PCA
Matrixcovariance , centered kernel ,
EigenvectorsPC directions in input spacecoefficients ; stays implicit
Max # componentsup to (can exceed )
Projection of x (with centering)
Reconstructioneasy: hard: needs a "pre-image" (Géron)
Costgrows with grows with (an eigenproblem)

With the linear kernel , kernel PCA gives back ordinary PCA (Problem 2 checks this on the worked example). Choosing the kernel and γ (Géron): kernel PCA is unsupervised, so there's no built-in score. Either grid-search them by the accuracy of a downstream classifier in a pipeline, or pick the setting with the lowest reconstruction pre-image error (fit_inverse_transform=True).

Quick check: 500 training points, each with 10,000 features. Which matrix does each method eigendecompose?

Linear PCA: the 10,000 × 10,000 covariance (or an SVD of the 500 × 10,000 data). Kernel PCA: the 500 × 500 kernel matrix. When , even linear PCA can be done this way, through (Bishop §12.1.4), which is the same trick.

Section 11

Independent component analysis (ICA)

Lecture 44:02–48:22Slides 34–35

PCA finds uncorrelated directions of maximum variance. ICA asks for something stronger: statistically independent components. The model is that each observation is a linear mix of hidden independent sources:

the independent source signals (coefficients)
the unknown mixing matrix; its columns are the "independent directions" (not necessarily orthogonal)

ICA estimates and by making the recovered components as independent as possible, measured by the mutual information between them (zero exactly when they're independent):

entropy; the sum of the individual entropies exceeds the joint entropy by exactly the shared information
PCA ICA
PCA averages; ICA aligns with the data's own edges. Two independent uniform sources mixed by a non-orthogonal matrix give a slanted parallelogram. PCA (left) returns perpendicular axes: the long diagonal and its normal, which match neither source. ICA (right, scikit-learn's FastICA) recovers the two mixing directions along the parallelogram's edges, which are not perpendicular.
Flagged in lecture · 45:36

"In terms of the concept, I prefer you remember this [figure], the difference between the ICA and the PCA … for the PCA you're trying to do the averaging … ICA is trying to find the individual directions among the data." That's slide 35: PCA finds directions of maximum variation; ICA finds the directions most "aligned" with the data.

Uses. Separating mixed signals: the classic is the cocktail party problem. Several people talk at once, several microphones each record a different mix, and ICA recovers each speaker's voice as a separate source. The same idea removes background noise from a phone call (46:46).

Heads up: slide 34 notation

Slide 34 writes the model as and two lines later as , and the product mixes indices and . Read both as the single model with sources and factors . Also, this (or ) is a mixing matrix, not PCA's orthonormal .

Quick check: why can't PCA solve the cocktail party problem?

PCA only makes the outputs uncorrelated and always returns orthogonal directions. The microphones' mixing directions generally aren't orthogonal, and uncorrelated is weaker than independent, so PCA's components are still blends of voices. ICA uses higher-order statistics (beyond the covariance) to find the truly independent sources.

Section 12

Cheat sheet

Center first; in kernel PCA, center
Covariance (: , centered); scatter
PC1 , largest
Variance along PC j; total
Two viewsmax variance = min reconstruction error (Pythagoras)
Project / reconstruct;
Reconstruction errormean
Choose ksmallest k with 90–95%
2×2 eigenvalues
SVD: PCs = columns of ; ; ; coords = ;
Power method; error shrinks by per step
Kernel PCA, ;
PCA limitssecond-order statistics only; linear only; scale-sensitive
ICA, independent; minimize mutual information; cocktail party
Section 13

Practice

Score: 0 / 0

Q1You run PCA on data whose mean is far from the origin, but forget to center it. What typically goes wrong?

Q2The covariance matrix is . What fraction of the variance does PC1 explain?

Q3Eigenvalues are 5, 3, 1, 1. How many components do you keep to preserve at least 90% of the variance?

Q4Why does maximizing the projected variance also minimize the reconstruction error?

Q5The SVD of a centered data matrix gives singular values . Which statement is right?

Q6Kernel PCA on 1,000 points with 50 features: what size matrix gets eigendecomposed?

Q72-D data, 100 points, RBF kernel PCA. At most how many components with nonzero variance can it find?

Q8Training mean (5, 3), PC1 . What is the PC1 coordinate of the new point (8, 4)?

Q9The power method converges slowest when the top two eigenvalues are:

Q10Three microphones record three people talking at once. Which method recovers each voice?

Problem 1: Run PCA by hand on (0,0), (2,2), (4,4), (6,2). Find the covariance (with 1/n), both eigenvalues and PC1, the explained-variance ratio, the 1-D coordinates, and the mean squared reconstruction error.

Center. Mean . Centered: , , , .

Covariance. , , . Divide by 4: .

Eigenvalues.

So , .

PC1. : , so .

Ratio. .

Coordinates. on centered points: , , , , approximately , , , . Mean square . ✓

Error. Reconstructions , , , ; squared errors ; mean . ✓

Checked with NumPy: eigenvalues (1, 6), reconstruction MSE 1.0.

Problem 2: Show that kernel PCA with the linear kernel reproduces ordinary PCA, using the worked example's centered points (−4,−2), (−2,0), (2,2), (4,0).

Kernel matrix. , entries :

The data is already centered, so .

Eigenvalues. has eigenvalues 44, 4, 0, 0. ( and always share their nonzero eigenvalues.) Then gives and : the same as the covariance eigenvalues.

Top eigenvector. The unit eigenvector for 44 is . Normalize: , so ✓.

Recover v and the projections. . The training projections are

exactly the PC1 coordinates from Section 6.

Checked with NumPy and with scikit-learn's KernelPCA(kernel="linear"), which returns the same coordinates up to sign.