ML Foundations

Learn / ML Foundations

ML Foundations: PCA and Dimensionality Reduction

Advanced quiz on centering, covariance matrices, principal components, projections, explained variance, whitening, and SVD connections.

Learning path

0%

0 of 4 sections marked complete · about 31 minutes

Learning objectives

What you will be able to explain

  • What does PCA optimize?
  • Center a tiny dataset
  • Compute a covariance matrix
  • What is the first principal direction here?
  • Compute an explained-variance ratio
  • Project onto a one-dimensional principal direction

Section 01

What does PCA optimize? to Compute a covariance matrix

01

What does PCA optimize?

PCA searches for orthogonal directions that capture variance efficiently. The first principal component is the variance-maximizing direction.

Guided checkpoint

Choose the best description of the first principal component.

02

Center a tiny dataset

The mean is ((1+3)/2,(1+3)/2)=(2,2)((1+3)/2, (1+3)/2) = (2, 2). Subtracting it from the first point gives (1,1)(-1, -1). PCA is usually performed after centering.

Guided checkpoint

Consider the two points (1,1)(1, 1) and (3,3)(3, 3). Compute the mean vector and the centered version of the first point.

03

Compute a covariance matrix

Here XX=[2222]X^\top X = \begin{bmatrix} 2 & 2 \\ 2 & 2 \end{bmatrix}, and dividing by n=2n = 2 gives [1111]\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}. The equal off-diagonal entries indicate perfect positive correlation.

Guided checkpoint

Using the centered points (1,1)(-1, -1) and (1,1)(1, 1), compute the population covariance matrix 1nXX\frac{1}{n}X^\top X.

Section 02

What is the first principal direction here? to Project onto a one-dimensional principal direction

01

What is the first principal direction here?

All variance lies along the line y=xy = x, so the first principal direction is along (1,1)(1, 1). The orthogonal direction (1,1)(1, -1) has zero variance here.

Guided checkpoint

For covariance matrix [1111]\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}, choose a direction of the first principal component.

02

Compute an explained-variance ratio

The total variance is 5+2+1=85 + 2 + 1 = 8. The first component explains 5/8=0.6255/8 = 0.625 of that total.

Guided checkpoint

If the covariance eigenvalues are 55, 22, and 11, what fraction of total variance is explained by the first principal component?

03

Project onto a one-dimensional principal direction

The coefficient is 2/2=22/\sqrt{2} = \sqrt{2}. Multiplying that by uu gives (1,1)(1, 1), which is the closest point to (2,0)(2, 0) on the subspace spanned by uu.

Guided checkpoint

Let u=(12,12)u = \left(\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}\right) and x=(2,0)x = (2, 0). Compute the projection coefficient uxu^\top x and the reconstructed point (ux)u(u^\top x)u.

Section 03

PCA facts: true or false to How is PCA related to SVD?

01

PCA facts: true or false

PCA is unsupervised and geometry-driven. Orthogonality and covariance eigenvectors are core facts, and scaling matters because variance is scale dependent.

Guided checkpoint

Mark each statement as true or false.

02

Match each PCA term to its meaning

These terms show up often in PCA discussions: loadings define directions, scores are projected coordinates, and explained variance quantifies compression quality.

Guided checkpoint

Match the term to the best description.

03

How is PCA related to SVD?

For centered data, the right singular vectors of the data matrix correspond to eigenvectors of XXX^\top X, which are the principal directions.

Guided checkpoint

Choose the best statement for centered data.

Section 04

What does whitening do after PCA? to What can happen if one feature scale dominates and the data is not standardized?

01

What does whitening do after PCA?

Whitening uses the PCA basis and rescales by eigenvalues so that transformed features are decorrelated and standardized in variance.

Guided checkpoint

Choose the best answer.

02

What can happen if one feature scale dominates and the data is not standardized?

Because PCA follows variance, raw scale can dominate the result. Standardization is often important when features are measured in incomparable units.

Guided checkpoint

Choose the most likely consequence.

Knowledge check

Turn understanding into recall.

The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.