PCA projection without covariance inversion
Question
Implement a training-only PCA fit and projection using SVD. Return k feature directions and explain what must be reused on test data.
Short answer
Centre with the training mean and use the first k right singular vectors as feature directions. Test rows must reuse both the mean and directions. Singular-vector signs can differ without changing the represented subspace.
Original question and answer written by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solutionLessons behind this question
- Principal Component Analysis and the SVD View
- The Supervised Learning Problem and the ML Pipeline
- Covariance and Correlation
Start with a free lesson: Expectation, Variance and Covariance is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.
Read it free