Principal Component Analysis

PCA is a method to reduce the dimensions of a Dataset while keeping most information. We do this by rotating the Dataset and projecting the points to one (or nn) dimensions.

To preserve distances and therefore information, you need to find the dimensions with highest Variance while discarding the ones with lowest variance.

Applications
  • image (data) compression
  • facial recognition with eigenfaces
  • anomaly detection (first k components show normal behaviour)

Limitation: Adidas Problem

How to calculate

XX is the input matrix with nn datapoints and pp features.

Optional but recommended:

  • standardize values (e.g. Z-score)

  • Calculate Eigenvalues and Eigenvectors of XX

    • Covariance matrix C=XXTC=XX^T
    • C=WLWTC = WLW^T where WW are the eigenvectors and LL are the eigenvalues on the diagonal in decreasing order
  • Alternatively perform a Singular Value Decomposition.

    • unitary matrix UU
    • matrix SS with singular values on the diagonal
    • matrix WW with the singular vectors
    • X=USWTX = USW^T

Inserting this into the covariance matrix will get us: WS2WTWS^2W^T" where the eigenvalues correspond to the squared singular values and the eigenvectors to the singular vectors.

Finally we can project the data with

T=XW.T = XW.

We then only want to keep the qq most important dimensions determined by the order of the λi\lambda_i.

Assess feature contributions

See Loading.