Concepts / Dimensionality Reduction

Dimensionality Reduction

Dimensionality reduction maps vectors from R^d to R^n using a linear transformation, where n is smaller than d.

  • Programming

Why Fewer Coordinates Matter

Suppose each data vector has d features. Working with every feature may be unnecessary when a smaller representation can retain the important structure of the data. Dimensionality reduction replaces a vector in a higher-dimensional space with a representation containing fewer coordinates. PCA performs this replacement through a linear transformation and evaluates it by how closely the original vector can later be approximated.

applyy = W xxvector in R^dWlinear transformationyvector in R^n
How does a vector in R^d move through a linear transformation into a vector in R^n when n is smaller than d?

The Compression Step

Start with one vector x in R^d. The compression matrix W has n rows and d columns, with n smaller than d. Multiplying W by x produces y = W x, a vector in R^n. The result y has fewer coordinates than x, so it is the compact representation of the original vector.

multipliesinput to WWn rows, d columnsxR^dyR^n
How does multiplying an original vector by W produce its lower-dimensional representation?

y = W x

A Symbolic Compression Trace

Following One Vector Through W

Describe the dimensions and role of each object when a vector x in R^d is compressed using a matrix W with n rows and d columns, where n is smaller than d.

Identify the input: The original vector is x, and it belongs to R^d. It therefore has d coordinates.

Inspect the matrix shape: W has n rows and d columns. Its d columns correspond to the d coordinates of x, and its n rows determine the dimension of the result.

Multiply: The product W x is defined and produces the compact vector y.

Identify the output: The compact representation y belongs to R^n. Since n is smaller than d, it has fewer coordinates than x.

The compression step maps x from R^d to y in R^n using y = W x.

Returning to the Original Space

Compression alone gives the smaller vector y. To return to the original dimensional setting, PCA uses a recovery matrix U. This matrix has d rows and n columns. Multiplying U by y produces the recovered vector, written as x_tilde = U y. The recovered vector lies in R^d, like the original x, but it is generally an approximation rather than a claim that every detail of x has been restored exactly.

inputx_tilde = U yyR^nUd rows, n columnsx_tildeR^d
How does the recovery matrix U transform the compressed representation back into an approximation in the original space?

x_tilde = U y

The Complete Reconstruction Pipeline

The full process has two linear transformations. First, W maps x from R^d into the smaller space R^n. Then U maps y back into R^d. Combining the two equations gives x_tilde = U W x. The result has the same dimensional setting as x, but it is a recovered approximation formed from the lower-dimensional representation.

inputy = W xinputx_tilde = U yxR^dWcompressionyR^nUrecoveryx_tildeR^d
What happens to a vector as it is compressed into fewer dimensions and then reconstructed into the original space?

When tracing dimensionality reduction, write down the space of every vector. The sequence is x in R^d, y in R^n, and x_tilde in R^d. This prevents the common mistake of treating the compressed vector and the recovered vector as if they lived in the same space.

How PCA Chooses W and U

PCA does not select W and U merely because their shapes are compatible. It chooses the pair so that recovered vectors stay close to the original vectors across the dataset. If the dataset contains vectors x_1 through x_m, each vector is compressed and recovered as x_tilde_i = U W x_i. PCA minimizes the total squared distance between every original vector x_i and its recovered version x_tilde_i.

Minimize the total squared distance between x_i and x_tilde_i, where x_tilde_i = U W x_i for i from 1 through m.

comparecomparex_ioriginal in R^dx_tilde_irecovered in R^dsquared distancebetween x_i and x_tilde_i
How does PCA judge the quality of compression and recovery using the squared distance between each original vector and its approximation?

Mistakes to Avoid

  • Treating dimensionality reduction as an arbitrary deletion of coordinates.

    The source defines the reduction as a linear transformation using the compression matrix W.

    Fix: Describe the compact representation as y = W x, where W maps R^d to R^n.

  • Giving W the wrong dimensions.

    The compression matrix has n rows and d columns.

    Fix: Remember that W has n rows and d columns, with n smaller than d.

  • Assuming recovery restores the original vector exactly.

    The recovered vector is generally an approximation of the original vector.

    Fix: Write x_tilde = U y and describe it as a vector in R^d that approximates x.

  • Optimizing only the compression matrix.

    PCA chooses the pair W and U so that reconstructed vectors are close to the originals.

    Fix: State the reconstruction as x_tilde_i = U W x_i and include both matrices in the optimization goal.

  • Measuring only whether the recovered vector has the right number of coordinates.

    PCA evaluates closeness using the total squared distance between original and recovered vectors.

    Fix: Connect the dimensionality change to the reconstruction-error objective.

Check Your Understanding

MEDIUM

A vector x belongs to R^d. A compression matrix W has n rows and d columns, with n smaller than d. Explain the space containing y = W x, the role of the recovery matrix U, and the quantity PCA minimizes across a dataset.

Hints
  • Use the number of rows of W to identify the dimension of y.
  • The recovery matrix has d rows and n columns.
  • Describe the objective using the squared distance between each x_i and x_tilde_i.
  1. Dimensionality reduction maps a vector from R^d to R^n through a linear transformation, with n smaller than d. The compression matrix W creates the compact representation y = W x. The recovery matrix U maps y back into R^d as the approximation x_tilde = U y. For a dataset, PCA chooses W and U to minimize the total squared distance between original vectors and their recovered approximations.

Key Takeaways

  • Dimensionality reduction maps vectors from R^d to the lower-dimensional space R^n, where n is smaller than d.
  • The compression matrix W produces the compact representation y = W x.
  • The recovery matrix U produces x_tilde = U y, an approximation in the original space R^d.
  • PCA chooses W and U to minimize the total squared distance between original and recovered vectors.
  • The central trade-off is fewer coordinates in the compact representation versus the reconstruction error after recovery.