Reconstruction Error from PCA
Dimensionality Reduction & Anomaly Detection DS practice problem on Onlearn.
Difficulty: medium.
Topics: Understanding Reconstruction Error as a Metric for Dimensionality Reduction, Mean Centering, Principal Component Selection, Frobenius Norm, Dimensionality Reduction, Reconstruction Loss, Linear Algebra, Statistical Learning, Data Preprocessing, Matrix Decomposition, Optimization Theory, Eigenvalue Decomposition, Singular Value Decomposition, Variance Maximization, Orthogonal Projections, Latent Space Representation.
Given a dataset X (as a numpy array) and a target number of components k, implement a function that calculates the Mean Squared Error (MSE) of the data reconstructed after performing PCA. The reconstruction is defined as X reconstructed = (X centered @ components.T) @ components + mean.