Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed
Machine Learning · Lecture 16 of 21 · 1:18:35
Lecture 15: PCA and ICA
Study guide
What this lecture covers
The lecture continues the unsupervised learning unit by introducing principal components analysis (PCA), a non-probabilistic alternative to the factor analysis model from the previous lecture, and then begins independent components analysis (ICA). The guiding question for PCA is: if your data appears to live near a lower-dimensional subspace of a high-dimensional space, how do you find that subspace and use it to compress the data, without building a full probabilistic model of p(x)?
This builds directly on the factor analysis lecture, contrasting PCA's non-probabilistic approach with factor analysis's probabilistic one, and it assumes comfort with covariance matrices, eigenvectors, and eigenvalues. After watching, you should be able to derive PCA as the eigenvectors of a data's covariance matrix, explain why mean-centering and variance-standardization matter as preprocessing steps, choose how many components to keep, judge when PCA is a good or questionable choice for a project, and describe what problem ICA is designed to solve.
Key ideas
- PCA finds a lower-dimensional subspace: given high-dimensional but not necessarily probabilistic data, PCA finds the directions along which the data varies most and projects the data onto them.
- Two equivalent derivations: PCA can be derived either by minimizing the sum of squared distances between points and their projections, or by maximizing the variance of the projected points; the lecture uses the variance-maximization view.
- Eigenvectors of the covariance matrix: the direction that maximizes projected variance, subject to being a unit vector, is the top eigenvector of the data's covariance matrix
Sigma; the topkeigenvectors define the bestk-dimensional subspace. - Preprocessing matters: subtracting the mean and standardizing each feature's variance before running PCA is necessary, since features on different scales, or data not centered at zero, will distort which direction PCA treats as principal.
- Compression and reconstruction: a
k-dimensional representationy_iis computed by projectingx_ionto the topkeigenvectors, and an approximate reconstruction ofx_ican be recovered as a weighted sum of those eigenvectors. - Good vs questionable uses: visualization of high-dimensional data and compression for computational efficiency are solid uses of PCA; using it to reduce overfitting or for outlier detection by distance in a reduced space is described as unreliable, working roughly as often as it fails.
- Choosing k: a common metric is the ratio of the sum of the top
keigenvalues to the sum of all eigenvalues, often reported as the fraction of variance retained (for example, 90% to 99%). - ICA and the cocktail party problem: given several microphone recordings, each a linear mixture of independent speaker signals, ICA recovers an unmixing matrix that separates the original sources, up to an unavoidable ambiguity in their order and sign.
Walkthrough
Motivating PCA with a correlated-features example (2:06)
The lecture opens with a simple case: measuring children's heights in both centimeters and inches produces two-dimensional data that is really only one-dimensional, since the two measurements are almost perfectly correlated, with a small amount of rounding noise. PCA is introduced as an algorithm that can discover this principal axis of variation and project the noisy two-dimensional data onto a cleaner one-dimensional line, without ever modeling a probability density. Additional motivating examples include two vibration sensors on the same machine and combining pilot-skill and pilot-enjoyment scores into a single aptitude measure.
Deriving PCA by maximizing projected variance (13:20)
After standardizing the data to zero mean and unit variance, the lecture sets up the optimization: find a unit vector U that maximizes the sum of squared lengths of the projections U^T x_i across the training set. Expanding this sum shows it equals U^T * Sigma * U, where Sigma is the data's covariance matrix. Maximizing this quantity subject to U being a unit vector, via a Lagrangian argument, shows that the maximizing U must satisfy Sigma*U = lambda*U, meaning U is an eigenvector of Sigma and the best choice is the eigenvector with the largest eigenvalue. The lecture notes this is one of several equivalent derivations of PCA, and that it is also equivalent to minimizing the sum of squared projection distances.
Reducing to k dimensions and reconstructing the data (22:32)
To project onto more than one dimension, the lecture generalizes to taking the top k eigenvectors of Sigma, each paired with its eigenvalue, and represents each example x_i with the k-dimensional vector y_i of projections onto these eigenvectors. Given the compressed representation y_i, the original high-dimensional example can be approximately reconstructed as a weighted sum of the eigenvectors using the y_i values as weights. Eigenvectors are chosen by taking those with the largest eigenvalues, and most numerical libraries already return them sorted this way.
Applications, and where PCA is a questionable choice (31:46)
Solid applications of PCA highlighted in the lecture include visualizing high-dimensional data in two or three dimensions, illustrated with a Stanford neuroscience project that reduced 50-dimensional brain electrode recordings to three dimensions to visualize a monkey planning a reaching movement, and compressing data to speed up downstream learning algorithms. The lecture is more skeptical of two other common uses: using PCA to reduce overfitting before training a classifier, and using distances in a PCA-reduced space for tasks like early face-matching systems (Eigenfaces); both are described as succeeding roughly as often as they fail, and Ng recommends regularization instead of PCA for overfitting, and testing whether a project's algorithm even needs PCA before adding it.
Choosing between PCA, factor analysis, k-means, and EM, and how many components to keep (49:11)
The lecture organizes the four unsupervised algorithms covered in the unit along two axes: whether the algorithm models a probability density p(x) and whether the data is assumed to live in a low-dimensional subspace or in clusters. This places factor analysis (probabilistic, subspace), PCA (non-probabilistic, subspace), mixture of Gaussians and EM (probabilistic, clusters or general latent-variable density estimation), and k-means (non-probabilistic, clusters) into a single framework. The lecture also addresses how many principal components to keep in practice, using the ratio of the sum of the top k eigenvalues to the sum of all eigenvalues as the fraction of variance retained, with values like 90% to 99% commonly reported after compressing high-dimensional data by a large factor.
Introducing ICA and the cocktail party problem (1:01:32)
The lecture pivots to independent components analysis, motivated by the cocktail party problem: several microphones each record an overlapping linear mixture of multiple speakers' voices, and the goal is to recover the original, separate voice signals from only the mixed recordings, played in a live audio demonstration. The model assumes observed signals x_i = A*s_i, where s_i are the true source signals and A is an unknown mixing matrix, and the algorithm's goal is to find an unmixing matrix W (approximately A inverse) that recovers the sources. The lecture closes by noting two unavoidable ambiguities in what ICA can recover: it cannot determine the original order of the sources, and it cannot determine their sign, though for audio this does not matter since a sound and its negation are indistinguishable to the ear.
Before you watch
- Review the factor analysis lecture, since this lecture explicitly contrasts PCA's non-probabilistic approach with factor analysis's probabilistic one.
- Be comfortable with covariance matrices, eigenvectors, and eigenvalues; the core PCA derivation depends on this linear algebra.
- Familiarity with the method of Lagrange multipliers is helpful for following the constrained-optimization argument, though the lecture notes it is not required to follow the result.
Check your understanding
- Why must the data be mean-centered and variance-standardized before running PCA?
- How does maximizing
U^T * Sigma * Usubject toUbeing a unit vector lead to the conclusion thatUmust be an eigenvector of the covariance matrix? - What does it mean to say a subspace spanned by the top
keigenvectors is stable while individual eigenvectors are not? - Why does the lecture recommend against using PCA to reduce overfitting, and what alternative is suggested instead?
- What are the two sources of ambiguity in what ICA can recover from a mixed audio signal, and why does the sign ambiguity not matter in practice for sound?
Vocabulary
- principal components analysis (PCA) (noun)
- A method that finds the directions of greatest variation in data to reduce its dimensions.
PCA compresses high-dimensional data onto a few key directions. - dimensionality reduction (noun)
- The process of representing data using fewer variables while keeping important information.
PCA is a common tool for dimensionality reduction. - subspace (noun)
- A smaller-dimensional space contained within a larger space.
PCA finds the subspace where the data varies the most. - projection (noun)
- The result of mapping a point onto a line, plane, or other subspace.
Each point's projection onto the principal axis captures most of its information. - variance (noun)
- A measure of how spread out a set of values is.
PCA finds the direction that maximizes the projected variance. - eigenvector (noun)
- A special direction that a matrix stretches without rotating.
The top eigenvector of the covariance matrix gives the main direction of variation. - eigenvalue (noun)
- The amount by which an eigenvector is stretched by a matrix.
A larger eigenvalue means that direction captures more variance. - mean-centering (noun)
- Shifting data so its average value becomes zero.
Mean-centering is a required preprocessing step before PCA. - standardize (verb)
- To rescale data so its features have comparable variance.
Standardizing prevents one feature's scale from dominating PCA. - reconstruction (noun)
- An approximate recovery of original data from a compressed representation.
Reconstruction rebuilds an approximate version of the original data point. - Lagrangian (noun)
- A mathematical technique for solving optimization problems with constraints.
A Lagrangian argument shows the best direction must be an eigenvector. - unit vector (noun)
- A vector with a length of exactly one.
PCA requires the direction U to be a unit vector. - outlier detection (noun)
- Identifying data points that are unusual compared to the rest.
PCA-based outlier detection is described as unreliable. - variance retained (noun)
- The proportion of total data variation kept after dimensionality reduction.
Choosing k often targets 90 to 99 percent variance retained. - independent components analysis (ICA) (noun)
- A method that separates mixed signals into their original independent sources.
ICA can separate mixed voices in the cocktail party problem. - mixing matrix (noun)
- A matrix describing how original signals are combined into observed recordings.
The unknown mixing matrix A combines the original voice signals. - unmixing matrix (noun)
- A matrix used to reverse a mixing process and recover original signals.
ICA finds the unmixing matrix W that separates the mixed recordings. - ambiguity (noun)
- A situation where more than one answer is equally valid, so the true one is unclear.
ICA has an ambiguity about the original order of the sources. - aptitude (noun)
- A natural ability or skill for a particular activity.
Combined scores can form a single aptitude measure. - electrode (noun)
- A sensor that detects or applies electrical signals, often used in brain recordings.
Brain electrode recordings were reduced to three dimensions with PCA.
From the YouTube description
For more information about Stanford’s Artificial Intelligence professional and graduate programs, visit: https://stanford.io/ai
Andrew Ng
Adjunct Professor of Computer Science
https://www.andrewng.org/
To follow along with the course schedule and syllabus, visit:
http://cs229.stanford.edu/syllabus-autumn2018.html
← Lecture 14: EM Algorithm and Factor Analysis · Lecture 16: Independent Component Analysis & Reinforcement Learning →
