Let’s say this is our data matrix (e.g. our houses), where each data point is a -dimensional row vector.

  1. Compute the mean row vector
  2. Compute the mean row matrix:

\bar X = \begin{pmatrix} 1 \ 1 \ \vdots \ 1 \end{pmatrix} \cdot \bar x^T = \begin{pmatrix} - & \bar x^T & - \ - & \bar x^T & - \ & \vdots \ - & \bar x^T & - \ \end{pmatrix} $$

The dimensions are . 3. Subtract mean (obtain mean centred data)

The dimensions are . 4. Compute the covariance matrix of rows of

The dimensions are . (more notes on why we do this below) 5. Compute the largest eigenvectors of C (not covered in module, use Python or WolframAlpha). Each eigenvector has dimensions .

Note

Depending on implementation, may not be sorted (e.g. certain Python libraries). Hence, sort eigenvectors by decreasing order of eigenvalues.

  1. Compute matrix of -largest eigenvectors. Dimensions of are .
  2. Multiply each datapoint for with . Dimensions of are

We’ve now reduced the number of dimensions from to .